Created
March 18, 2020 09:35
-
-
Save Steinhagen/007cb60924d4f4b16b8dde72c50c611e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import gi | |
gi.require_version('Gtk', '3.0') | |
from gi.repository import Gtk | |
from gi.repository import Gio | |
import sys | |
class Window(Gtk.ApplicationWindow): | |
def __init__(self, app): | |
super(Window, self).__init__(title="Application", application=app) | |
grid = Gtk.Grid() | |
menubar = Gtk.MenuBar() | |
fmi = Gtk.MenuItem.new_with_label("File") | |
menu = Gtk.Menu() | |
emi = Gtk.MenuItem.new_with_label("Exit") | |
emi.connect("activate", self.quitApp) | |
menu.append(emi) | |
fmi.set_submenu(menu) | |
menubar.add(fmi) | |
grid.attach(menubar, 0, 0, 1, 1) | |
self.add(grid) | |
self.set_default_size(280, 180) | |
def quitApp(self, par): | |
app.quit() | |
class Application(Gtk.Application): | |
def __init__(self): | |
super(Application, self).__init__() | |
def do_activate(self): | |
self.win = Window(self) | |
self.win.show_all() | |
def do_startup(self): | |
Gtk.Application.do_startup(self) | |
app = Application() | |
app.run(sys.argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment