i am trying to make a password system that will run another one of my programs when answered correctly. not sure how to call my main program in the password prog function. i have played w this over and over, and browsed the library and i am officially stuck. :)

heres my password prog:

#!user/bin/python

from Tkinter import *

def GetValue():

password= ent.get()
if password == 'harmoni':
menu_widget_test.pyw #this is name of main prog to be called
ent.delete(0,END)
else:
lab2=Label(root, text= 'try again').pack()
ent.delete(0,END)

root = Tk()
root.geometry('150x200+500+200')

lab = Label(root, text= 'password')
ent = Entry(root, bg = 'white')
button = Button(root, text = 'Enter Password', command = GetValue)

ent.focus()

lab.pack(anchor = W)


ent.pack(anchor = W)
button.pack(anchor = E)

root.mainloop()

You need to put your code in the code tags.

I have not worked with Tkinter and don't understand how the program you are working on should work. What is

menu_widget_test.pyw

If you want to run a different module you need to import it at some point or if you want to use a different class, saved in the same file, you need to create an instance of it.

Perhaps I am wrong, but I think that you are trying to do gui programming before you have really got basic console Python down first. If so, you are going to find actually getting your programs to do stuff rather tricky.

If you want to use different files/modules you will find it much easier to use classes or even just functions to hide the passwords in namespaces. Something as simple as:

def call_if_good():
    if x == "password"
        y = 'in'
    
if y == in:
    from myprogram.py import TheClass
    stuff = TheClass(variables='more stuff')
    stuff.doThingsForMe()

Or something like that effect.

yea, i may be getting ahead of myself, i just started learning python (my very first and only lang at this point) about 5 days ago. and that widget_test.py is the other program i wrote that im trying to password protect it from running. its just a simple toplevel/textbox widget w some menubar options in it. just doing this for practice, tinkering with some of the projects i have learned so far from video tutorials. tyvm. :)

This article has been dead for over six months. Start a new discussion instead.