I have the following code with several problems. The first of which is the createUser() command will run immediately after the window appears.
The second is my button tied to that command will not run the command itself (I have tested this by attempting to print a simple string back into IDLE).
The last problem I seem to have is my label does not update when I set the variable to different contents, even when .set() is used outside of the command.
root = tk.Tk()
root.title("Sign In Screen")
tk.Label(root,text="Username: ",font="Arial").grid(row=0,column=0)
userIDEntry = tk.Entry(root)
userIDEntry.grid(row=0,column=1)
tk.Label(root,text="Password: ",font="Arial").grid(row=1,column=0)
passwordEntry = tk.Entry(root)
passwordEntry.grid(row=1,column=1)
tk.Label(root,text="Confirm Password: ",font="Arial").grid(row=2,column=0)
passwordConfirm = tk.Entry(root)
passwordConfirm.grid(row=2,column=1)
def createAccount():
if passwordEntry.get() == passwordConfirm.get():
exampleFunction() #doesntwork
else:
var1.set("Passwords do not match!")
root.update()
var1 = tk.StringVar()
var1.set("")
tk.Button(root,text="CREATE ACCOUNT",font="Arial",command=createAccount()).grid(row=3,column=0,columnspan=2)
tk.Label(root,textvariable=var1).grid(row=4,column=0,columnspan=2)
root.mainloop()
I hope someone can help me out, I'm trying to teach myself Tkinter and can't stop running into small issues like these.