summaryrefslogtreecommitdiffstats
path: root/Demo/tkinter/guido/optionmenu.py
blob: be9d3ac2a64180a8a67e7309ce5265c862db4885 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# option menu sample (Fredrik Lundh, September 1997)

from Tkinter import *

root = Tk()

#
# standard usage

var1  = StringVar()
var1.set("One") # default selection

menu1 = OptionMenu(root, var1, "One", "Two", "Three")
menu1.pack()

#
# initialize from a sequence

CHOICES = "Aah", "Bee", "Cee", "Dee", "Eff"

var2  = StringVar()
var2.set(CHOICES[0])

menu2 = apply(OptionMenu, (root, var2) + tuple(CHOICES))
menu2.pack()

root.mainloop()