[Tutor] Dynamically populate Tkinter OptionMenu with list
Bernard Lebel
3dbernard at gmail.com
Thu Jul 21 18:14:42 CEST 2005
Thanks John.
Bernard
On 7/20/05, jfouhy at paradise.net.nz <jfouhy at paradise.net.nz> wrote:
> Quoting Bernard Lebel <3dbernard at gmail.com>:
>
> > I have this problem. I build a list of elements, and I never know in
> > advance how many or what will be the elements.
> >
> > I then wish to populate an OptionMenu with this list of elements.
>
> Do you know the list of elements before you create the option menu?
>
> If so, you can do something like this:
>
> # suppose aElements is the list of elements, and var1 is a StringVar.
> oOption = OptionMenu(oRoot, var1, aElements[0], *aElements[1:])
>
> If you want to create the OptionMenu first, and then later set the list of
> elements ... then it is a bit more difficult.
>
> --
> John.
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list