I'm a beginner trying to code a program that will add or delete a widget (checkbutton) depending on the value of the entry. For example, if the entry is greater than 1, the checkbox will be added, otherwise, the program will delete the checkbox.
My code will create the widget but won't delete it after changing the entry and I can't figure it out. Can you help me please?
Thank you in advance for your help!
Here's a short sample of my code:
from Tkinter import *
root = Tk()
def update(*args):
print EntryVar.get()
if EntryVar.get()>'1':
cb = Checkbutton(root,text="Show check box")
cb.grid(row = 1)
elif EntryVar.get()<='1' or EntryVar.get() == '':
try:
cb.grid_remove()
except:
pass
EntryVar = StringVar()
EntryVar.trace('w',update)
Entry = Entry(root,textvariable = EntryVar)
Entry.grid(row = 0)
root.mainloop()
Let me know if you need more details :)