I don't believe there is any way to create an OptionMenu without using a Tk variable.
However, if all you want to do is to change the value of an already
created OptionMenu without using the variable, you can do this:
import Tkinter as Tk
root = Tk.Tk()
var = Tk.StringVar()
om = Tk.OptionMenu(root, var, 'a', 'b', 'c')
om['menu'].invoke(index)
where index is the index of the value you want to select. In this case,
index=0 for 'a', 1 for 'b', or 2 for 'c'.
I'm not sure that's really an improvement for you, but it works.
Also note - you can add additional options after creation to the
OptionMenu through a bit of a backdoor using a private Tk function (so
this isn't strictly recommended, I guess) using the following syntax:
om['menu'].add_command(label='new_value', command=Tk._setit(var,
'new_value'))
Dave
> The conventional way goes this
> var = Stringvar()
> var.set('value')
> But i want to happen without using the variable. Can someone help me out
on
> this?
David J. Giesen | Research Scientist | FPEG US Display OLED Materials R+D
|
Eastman Kodak Company | 2/83/KRL MC02216 | Rochester, NY 14650 |
[email protected] | 1-585-588-0480 Office |
www.kodak.com
<<image/gif>>
_______________________________________________ Tkinter-discuss mailing list [email protected] http://mail.python.org/mailman/listinfo/tkinter-discuss
