Thank you very much. It seems it works. How ever, if I don't use a
command=lambda... in the add_command I cannot get the OptionMenu value
changed (see below). Is it really necessary all the lambda... function I
am doing or there is a smarter way of doing the job?
Regards
Vasillis
--------
from Tkinter import *
values = ["one","two","three"]
root = Tk()
var = StringVar()
var.set(values[0])
# set initial options
o = OptionMenu(root,var,*values)
o.pack()
# change options
m = o.children['menu']
m.delete(0,END)
newvalues = "a b c d e f".split()
for val in newvalues:
m.add_command(label=val,command=lambda v=var,l=val:v.set(l))
var.set(newvalues[0])
root.mainloop()
---------
[EMAIL PROTECTED] wrote:
Vasilis Vlachoudis wrote:
values=["One","Two","Three"] # Initial list
o = OptionMenu(frame, *values)
#...
#then later in the code read new values from a file
newvalues = f.readline().split()
o.config(???=newvalues)
With
m = o.children ['menu']
you can access the menu which implements the OptionMenu.
OptionMenu uses 'command' entries.
So you can add new entries with
m.add_command(label='a_new_entry',command=if_you_need_to_set_a_var_or_something)
I never used this personally.
Hope it works for you.
Matthias Kievernagel
mkiever at web dot de
_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss
begin:vcard
fn:Vasilis Vlachoudis
n:Vlachoudis;Vasilis
org:CERN;AB
adr:CERN;;Dep.AB;Geneva-23;;CH-1211;Switzerland
email;internet:[EMAIL PROTECTED]
title:Dr
tel;work:+41-22-767.9851
tel;fax:+41-22-767.7555
tel;cell:+41-76-487.4378
x-mozilla-html:FALSE
url:http://home.cern.ch/bnv
version:2.1
end:vcard
_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss