| 1 |
import gi |
| 2 |
|
| 3 |
gi.require_version("Gtk", "4.0") |
| 4 |
from gi.repository import Gtk |
| 5 |
|
| 6 |
|
| 7 |
class HeaderBarWindow(Gtk.ApplicationWindow): |
| 8 |
def __init__(self, **kargs): |
| 9 |
super().__init__(**kargs, default_width=400, title="HeaderBar Example") |
| 10 |
|
| 11 |
header_bar = Gtk.HeaderBar() |
| 12 |
self.set_titlebar(header_bar) |
| 13 |
|
| 14 |
button = Gtk.Button(label="Button") |
| 15 |
header_bar.pack_start(button) |
| 16 |
|
| 17 |
icon_button = Gtk.Button(icon_name="open-menu-symbolic") |
| 18 |
header_bar.pack_end(icon_button) |
| 19 |
|
| 20 |
|
| 21 |
def on_activate(app): |
| 22 |
# Create window |
| 23 |
win = HeaderBarWindow(application=app) |
| 24 |
win.present() |
| 25 |
|
| 26 |
|
| 27 |
app = Gtk.Application(application_id="com.example.App") |
| 28 |
app.connect("activate", on_activate) |
| 29 |
|
| 30 |
app.run(None) |