Hi,
On Wed, 4 Nov 2009 08:23:39 -0500
[email protected] wrote:
> I don't believe there is any way to create an OptionMenu without
> using a Tk variable.
Actually you can:
<code>
from Tkinter import *
root = Tk()
om = OptionMenu(root, None, '1', '2')
om.pack(padx=100, pady=100)
items = ('a', 'b', 'c', 'd')
def callback(item):
om.configure(text=item)
print 'selected:', item
om['menu'].delete(0, 'end')
for x in items:
om['menu'].add_command(label=x, command=lambda item=x: callback(item))
callback('a')
root.mainloop()
</code>
I needed this once, because I was not able to handle unicode filenames
properly using a Tk textvariable, so you see it looks overly
complicated but in some cases may have its use.
I hope this helps
Michael
_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss