• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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()
28