source: branches/GUIdev/Original Trial Files (9 December 2013)/menuTrial.py @ 1441

Last change on this file since 1441 was 1306, checked in by KelvinHsu, 11 years ago

Initial commit of early python tests

File size: 889 bytes
Line 
1from Tkinter import *
2
3root = Tk()
4
5def hello():
6    print "hello!"
7
8menubar = Menu(root)
9
10# create a pulldown menu, and add it to the menu bar
11filemenu = Menu(menubar, tearoff=0)
12filemenu.add_command(label="Open", command=hello)
13filemenu.add_command(label="Save", command=hello)
14filemenu.add_separator()
15filemenu.add_command(label="Exit", command=root.quit)
16menubar.add_cascade(label="File", menu=filemenu)
17
18# create more pulldown menus
19editmenu = Menu(menubar, tearoff=0)
20editmenu.add_command(label="Cut", command=hello)
21editmenu.add_command(label="Copy", command=hello)
22editmenu.add_command(label="Paste", command=hello)
23menubar.add_cascade(label="Edit", menu=editmenu)
24
25helpmenu = Menu(menubar, tearoff=0)
26helpmenu.add_command(label="About", command=hello)
27menubar.add_cascade(label="Help", menu=helpmenu)
28
29# display the menu
30root.config(menu=menubar)
31
32
33root.mainloop()
34root.destroy()
Note: See TracBrowser for help on using the repository browser.