3
# some vocabulary to keep from getting confused. This terminology
4
# is something I cooked up for this file, but follows the man pages
14
# +------------++------------++------------+
16
# | File || Edit || Options | <-------- the MENUBAR
18
# +------------++------------++------------+
22
# | | <------ This is a MENU. The lines of text in the menu are
25
# | Open Files > | file1 |
27
# | | another file | <------ this cascading part is also a MENU
28
# +----------------| |
37
print("opening new file")
41
print("opening OLD file")
45
# make menu button : "File"
46
File_button = Menubutton(mBar, text='File', underline=0)
47
File_button.pack(side=LEFT, padx="1m")
48
File_button.menu = Menu(File_button)
50
# add an item. The first param is a menu entry type,
51
# must be one of: "cascade", "checkbutton", "command", "radiobutton", "separator"
52
# see menu-demo-2.py for examples of use
53
File_button.menu.add_command(label='New...', underline=0,
57
File_button.menu.add_command(label='Open...', underline=0,
60
File_button.menu.add_command(label='Quit', underline=0,
63
# set up a pointer from the file menubutton back to the file menu
64
File_button['menu'] = File_button.menu
71
Edit_button = Menubutton(mBar, text='Edit', underline=0)
72
Edit_button.pack(side=LEFT, padx="1m")
73
Edit_button.menu = Menu(Edit_button)
75
# just to be cute, let's disable the undo option:
76
Edit_button.menu.add('command', label="Undo")
77
# Since the tear-off bar is the 0th entry,
78
# undo is the 1st entry...
79
Edit_button.menu.entryconfig(1, state=DISABLED)
81
# and these are just for show. No "command" callbacks attached.
82
Edit_button.menu.add_command(label="Cut")
83
Edit_button.menu.add_command(label="Copy")
84
Edit_button.menu.add_command(label="Paste")
86
# set up a pointer from the file menubutton back to the file menu
87
Edit_button['menu'] = Edit_button.menu
92
#################################################
94
#### Main starts here ...
99
mBar = Frame(root, relief=RAISED, borderwidth=2)
102
File_button = makeFileMenu()
103
Edit_button = makeEditMenu()
105
# finally, install the buttons in the menu bar.
106
# This allows for scanning from one menubutton to the next.
107
mBar.tk_menuBar(File_button, Edit_button)
109
root.title('menu demo')
110
root.iconname('packer')