Adding command to a Tkinter OptionMenu?
问题 I'm writing some code in Python 2.7.8 which includes the OptionMenu widget. I would like to create an OptionMenu that calls a function when the option is changed but I also want the possible options to be found in a list, as my final OptionMenu will have many options. I have used the following code to create an OptionMenu that calls a function: from Tkinter import* def func(value): print(value) root = Tk() var = StringVar() DropDownMenu=OptionMenu(root, var, "1", "2", "3", command=func)