Python... Hide widget upon menu option selection - Tkinter -


working tkinter, trying make label disappear , appear in place when specific option selected menuoption(). can accomplish without need of "refresh" button?

updated sample of code:

mgui = tk() mgui.geometry('570x130+700+200') mgui.resizable(width = false, height = false) mgui.title('title')   mylist = ['henry', 'tom', 'phil'] somevalue = stringvar()  mlabel = label(text = 'name:  ').grid(row = 0, column = 0, sticky = e)  somemenu = optionmenu(mgui, somevalue, *mylist) somemenu.grid(row = 0, column = 1, sticky = w) somemenu.config(width = 14, anchor = w)  mgui.mainloop() 

so, if somemenu.get() == 'tom' want hide mlabel...

so i've added following:

def something():         print somevalue.get()  mylist = ['henry', 'tom', 'phil'] somevalue = stringvar() somevalue.trace('w', something) 

and getting typeerror: 'nonetype' object not callable.. hmmmmm

you can put trace on somevalue, can call function whenever value changes. in function can want, including removing widgets.

this website has example: http://effbot.org/tkinterbook/variable.htm


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -