Reputation: 2015
For some reason I can't get this optionmenu so call the callback function. Is there some special treatment those widgets require? (The function itself works and I can call it from i.e. a button.)
self.shapemenu=Tkinter.OptionMenu(self.frame,self.shape,"rectangle", "circular", command=self.setshape)
self.shape is a Tkinter.StringVar and obviously setshape is the callback function.
What am I doing wrong here?
Upvotes: 3
Views: 1300
Reputation: 386342
The optionmenu is designed to set a value, not perform an action. You can't assign a command to it, and if you do, you will break its default behavior of setting the value -- it uses the command option internally to manage its values .
If you want something to happen when the value changes, add a trace on the StringVar.
Upvotes: 6