class MyWindow(Gtk.ApplicationWindow):
# constructor for a Gtk.ApplicationWindow
def __init__(self, app):
Gtk.Window.__init__(self, title="Hello World!", application=app)
self.set_default_size(200, 100)
class MyApplication(Gtk.Application):
def __init__(self):
Gtk.Application.__init__(self)
def do_activate(self):
win = MyWindow(self)
win.show_all()
def do_startup(self):
Gtk.Application.do_startup(self)
Gtk.Application initializes GTK+. It also connects the
We can start building our first window. We do this by creating a class called MyWindow and assigning it a Gtk.ApplicationWindow.
We give the window a property called title. The title can be any string you want it to be. To be on the safe side, it's best to stick to UTF-8 encoding.
Now we have a window which has a title and a working "close" button. Let's add the actual "Hello World" text.