Optionmenu.

Michael Peuser mpeuser at web.de
Thu Sep 4 15:17:24 EDT 2003


"Thor" <thor__00 at yahoo.com> schrieb im Newsbeitrag
news:bj7j47$g5rpn$1 at ID-108351.news.uni-berlin.de...
> I have the following function (with some things removed):
>
> def add_stock():
>     stockw=Tk()
>     stockw.title("New stock solution")
>     sofl=Frame(stockw)
>     sofl.pack()
>     u=StringVar()
>     u.set("M")
>     cw=OptionMenu(sofl,u,"M","m","u","v","w")
>     cw.grid(row=1,column=2)
>
> but the widget keeps not showing teh selected option. If I fo the same out
> of the function it works without problem (with stockw.mainloop()). What am
> I missing? Anybody can point me out to the solution/the right webpage?
> --

Works fine with Python 2.2 Tk8.3.
Though it's looks a little bit funny that you initialize Tk inside the
function and that you use a local variable u for your your interface...


Kindly
Michael P






More information about the Python-list mailing list