Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fe78cc0

Browse files
committed
Adding Fredrik Lundh's demo of the option menu.
1 parent f574500 commit fe78cc0

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

Demo/tkinter/guido/optionmenu.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# option menu sample (Fredrik Lundh, September 1997)
2+
3+
from Tkinter import *
4+
5+
root = Tk()
6+
7+
#
8+
# standard usage
9+
10+
var1 = StringVar()
11+
var1.set("One") # default selection
12+
13+
menu1 = OptionMenu(root, var1, "One", "Two", "Three")
14+
menu1.pack()
15+
16+
#
17+
# initialize from a sequence
18+
19+
CHOICES = "Aah", "Bee", "Cee", "Dee", "Eff"
20+
21+
var2 = StringVar()
22+
var2.set(CHOICES[0])
23+
24+
menu2 = apply(OptionMenu, (root, var2) + tuple(CHOICES))
25+
menu2.pack()
26+
27+
root.mainloop()

0 commit comments

Comments
 (0)