summaryrefslogtreecommitdiffstats
path: root/Demo/tkinter/guido/optionmenu.py
blob: 7365fa628e5e9aba6937c6091b56f611bda6e7a6 (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 = OptionMenu(root, var2, *CHOICES)
menu2.pack()

root.mainloop()