1from gi.repository import Gtk 2import sys 3 4 5class MyWindow(Gtk.ApplicationWindow): 6 # constructor for a Gtk.ApplicationWindow 7 8 def __init__(self, app): 9 Gtk.Window.__init__(self, title="Welcome to GNOME", application=app) 10 self.set_default_size(200, 100) 11 12 # create a label 13 label = Gtk.Label() 14 # set the text of the label 15 label.set_text("Hello GNOME!") 16 # add the label to the window 17 self.add(label) 18 19 20class MyApplication(Gtk.Application): 21 22 def __init__(self): 23 Gtk.Application.__init__(self) 24 25 def do_activate(self): 26 win = MyWindow(self) 27 win.show_all() 28 29 def do_startup(self): 30 Gtk.Application.do_startup(self) 31 32app = MyApplication() 33exit_status = app.run(sys.argv) 34sys.exit(exit_status) 35