[Tkinter-discuss] optionmenu insert

Pavel Kosina geon at post.cz
Tue May 2 14:32:17 CEST 2006


Michael Lange napsal(a):
> Hi Pavel,
>
> you can access the OptionMenu's Menu by its 'menu' key:
>
>   
>>>> from Tkinter import *
>>>> root = Tk()
>>>> s = StringVar()
>>>> s.set('eggs')
>>>> o = OptionMenu(root, s, 'eggs', 'spam', 'foo', 'bar')
>>>> o.pack()
>>>> o['menu'].insert('end', 'command', label='blah')
>>>>         
Just found there is another trouble with this. Maybe I could help 
myself, but dont know how to get from tk documentation what you have 
written - how to know why "command" should be there, why ["menu"], etc.

Anyway, I have:

w = OptionMenu(root, var,u"one", u"two", u"...",command=ok)
w.pack()
w["menu"].insert(2, "command", label=u"three")

When I choose "three" then, the function 'ok' is not called. It must be 
another argument in last line, I think.


Thank you

-- 
Pavel Kosina



More information about the Tkinter-discuss mailing list