[Tutor] Dynamically populate Tkinter OptionMenu with list
3dbernard at gmail.com
Thu Jul 21 18:14:42 CEST 2005
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, *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.
> Tutor maillist - Tutor at python.org
More information about the Tutor