I am dealing with problem that my if/else statement does not work, when the condition is met.
The point is that I want to set my button ("submit") config to the state=NORMAL, when there is more than one character in entry area. I think the code is correct, but the problem may be caused by statics of the code. In other cases it requires the command (click, or other event) to be called, but here it is only change of entry content and I am not sure how to code it.
Below is the function with the button and my if/else statement. I am grateful for your help and every kind of advice.
def sign():
infoLabel = Label(root, text="Enter your name: ").grid(row=0, column=0)
global e
e = Entry(root, width=25)
e.grid(row=0, column=1, columnspan=2)
submit = Button(root, text="Submit", command=signbtn)
submit.grid(row=0, column=3)
if len(e.get()) == 0:
submit.config(state=DISABLED)
else:
submit.config(state=NORMAL)
Aucun commentaire:
Enregistrer un commentaire