forked from buckyroberts/Source-Code-from-Tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path23_menu.py
More file actions
45 lines (32 loc) · 1.15 KB
/
23_menu.py
File metadata and controls
45 lines (32 loc) · 1.15 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from gi.repository import Gtk
# gsettings set com.canonical.Unity always-show-menus true
class MenuExampleWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="")
self.set_default_size(400, 300)
# Layout
layout = Gtk.Box()
self.add(layout)
# Main container that we will stick inside our layout
main_menu_bar = Gtk.MenuBar()
# Drop down menu
file_menu = Gtk.Menu()
file_menu_dropdown = Gtk.MenuItem("File")
# File menu items
file_new = Gtk.MenuItem("New")
file_open = Gtk.MenuItem("Open")
file_exit = Gtk.MenuItem("Exit")
# File button has dropdown
file_menu_dropdown.set_submenu(file_menu)
# Add menu items
file_menu.append(file_new)
file_menu.append(file_open)
file_menu.append(Gtk.SeparatorMenuItem())
file_menu.append(file_exit)
# Add to main menu bar
main_menu_bar.append(file_menu_dropdown)
layout.pack_start(main_menu_bar, True, True, 0)
window = MenuExampleWindow()
window.connect("delete-event", Gtk.main_quit)
window.show_all()
Gtk.main()