blob: 1e72aa58954a73187ebb15340bef699931489bd8 (
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()
|