On Mon, 01 May 2006 18:06:24 +0200 Pavel Kosina <[EMAIL PROTECTED]> wrote:
> Hi, > > I dont know how to dynamically add items to optionmenu. > I found this > http://aspn.activestate.com/ASPN/docs/ActiveTcl/iwidgets/optionmenu.n.html > insert method, but it is not working or wrong done by me. > > w = OptionMenu(master, variable, *OPTIONS ) > w.insert(1,"something") > > Neither dir(w) nor print w.config() didnt help much. > 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') I hope this helps Michael _______________________________________________ Tkinter-discuss mailing list [email protected] http://mail.python.org/mailman/listinfo/tkinter-discuss
