summaryrefslogtreecommitdiff
path: root/pypers/pycon10/menu2.py
diff options
context:
space:
mode:
Diffstat (limited to 'pypers/pycon10/menu2.py')
-rw-r--r--pypers/pycon10/menu2.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/pypers/pycon10/menu2.py b/pypers/pycon10/menu2.py
new file mode 100644
index 0000000..d148389
--- /dev/null
+++ b/pypers/pycon10/menu2.py
@@ -0,0 +1,13 @@
+import Tkinter
+root = Tkinter.Tk()
+text = Tkinter.StringVar()
+label = Tkinter.Label(root, textvariable=text)
+menubar = Tkinter.Menu(root)
+menu = Tkinter.Menu(menubar)
+menubar.add_cascade(label='File', menu=menu)
+for item in ['F1','F2', 'F3']:
+ def showmenu(item=item):
+ text.set(text.get() + '\n%s' % item)
+ menu.add_command(label=item, command=showmenu)
+root.config(menu=menubar); label.pack()
+root.mainloop()