| 1 | # i hate blueprint files! |
| 2 | import gi |
| 3 | |
| 4 | gi.require_version("Gtk", "4.0") |
| 5 | gi.require_version("Adw", "1") |
| 6 | from gi.repository import GLib, Gtk, Adw |
| 7 | |
| 8 | |
| 9 | class MyApplication(Adw.Application): |
| 10 | def __init__(self): |
| 11 | super().__init__(application_id="com.example.MyGtkApplication") |
| 12 | GLib.set_application_name("My Gtk Application") |
| 13 | |
| 14 | def do_activate(self): |
| 15 | window = Adw.ApplicationWindow(application=self, title="Hello World") |
| 16 | window.set_default_size(400, 600) |
| 17 | |
| 18 | toolbar = Adw.ToolbarView() |
| 19 | window.set_content(toolbar) |
| 20 | |
| 21 | header_bar = Adw.HeaderBar() |
| 22 | toolbar.add_top_bar(header_bar) |
| 23 | |
| 24 | box = Gtk.Box() |
| 25 | box.set_halign(Gtk.Align.CENTER) |
| 26 | box.set_valign(Gtk.Align.CENTER) |
| 27 | toolbar.set_content(box) |
| 28 | |
| 29 | label = Gtk.Label() |
| 30 | label.set_label("lmao") |
| 31 | box.append(label) |
| 32 | |
| 33 | window.present() |
| 34 | |
| 35 | |
| 36 | app = MyApplication() |
| 37 | app.run() |
| 38 |
sklly / GTK + Adw Python Examples
Last active 1 hour ago
Python examples of a GTK/Adw app. Can be run as is on a linux system