| 1 |
import gi |
| 2 |
|
| 3 |
gi.require_version("Gtk", "4.0") |
| 4 |
from gi.repository import Gtk |
| 5 |
|
| 6 |
|
| 7 |
class MyWindow(Gtk.ApplicationWindow): |
| 8 |
def __init__(self, **kargs): |
| 9 |
super().__init__(**kargs, title="Hello World") |
| 10 |
|
| 11 |
self.button = Gtk.Button(label="Click Here") |
| 12 |
self.button.connect("clicked", self.on_button_clicked) |
| 13 |
self.set_child(self.button) |
| 14 |
|
| 15 |
def on_button_clicked(self, _widget): |
| 16 |
self.close() |
| 17 |
|
| 18 |
|
| 19 |
def on_activate(app): |
| 20 |
# Create window |
| 21 |
win = MyWindow(application=app) |
| 22 |
win.present() |
| 23 |
|
| 24 |
|
| 25 |
app = Gtk.Application(application_id="com.example.App") |
| 26 |
app.connect("activate", on_activate) |
| 27 |
|
| 28 |
app.run(None) |