diff --git a/PythonGTK/Examples/23_menu.py b/PythonGTK/Examples/23_menu.py index 5b4f075..fffde4e 100644 --- a/PythonGTK/Examples/23_menu.py +++ b/PythonGTK/Examples/23_menu.py @@ -1,45 +1,51 @@ from gi.repository import Gtk -# gsettings set com.canonical.Unity always-show-menus true -class MenuExampleWindow(Gtk.Window): +class MenuWindow(Gtk.Window): + def __init__(self): Gtk.Window.__init__(self, title="") - self.set_default_size(400, 300) + + self.set_border_width(10) + self.set_default_size(500, 400) + + + header_bar = Gtk.HeaderBar() + header_bar.set_show_close_button(True) + header_bar.props.title = "Rippin Music Player" + self.set_titlebar(header_bar) + box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) - # Layout - layout = Gtk.Box() - self.add(layout) - # Main container that we will stick inside our layout main_menu_bar = Gtk.MenuBar() + box.add(main_menu_bar) + # 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) + + header_bar.pack_start(box) -window = MenuExampleWindow() +window = MenuWindow() window.connect("delete-event", Gtk.main_quit) window.show_all() Gtk.main()