PageRenderTime 54ms CodeModel.GetById 30ms app.highlight 9ms RepoModel.GetById 11ms app.codeStats 1ms

/Demo/tkinter/guido/optionmenu.py

http://unladen-swallow.googlecode.com/
Python | 27 lines | 12 code | 10 blank | 5 comment | 0 complexity | 1ec99b28d4277f32485c29d930bce277 MD5 | raw file
 1# option menu sample (Fredrik Lundh, September 1997)
 2
 3from Tkinter import *
 4
 5root = Tk()
 6
 7#
 8# standard usage
 9
10var1  = StringVar()
11var1.set("One") # default selection
12
13menu1 = OptionMenu(root, var1, "One", "Two", "Three")
14menu1.pack()
15
16#
17# initialize from a sequence
18
19CHOICES = "Aah", "Bee", "Cee", "Dee", "Eff"
20
21var2  = StringVar()
22var2.set(CHOICES[0])
23
24menu2 = apply(OptionMenu, (root, var2) + tuple(CHOICES))
25menu2.pack()
26
27root.mainloop()