Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menu.py code update #138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions PythonGTK/Examples/23_menu.py
Original file line number Diff line number Diff line change
@@ -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()