Re: [Tutor] Dynamically populate Tkinter OptionMenu with list

2005-07-21 Thread Bernard Lebel
Thanks John.

Bernard


On 7/20/05, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Quoting Bernard Lebel [EMAIL PROTECTED]:
 
  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@python.org
 http://mail.python.org/mailman/listinfo/tutor

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Dynamically populate Tkinter OptionMenu with list

2005-07-20 Thread jfouhy
Quoting Bernard Lebel [EMAIL PROTECTED]:

 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@python.org
http://mail.python.org/mailman/listinfo/tutor