Debian Codegraph @

docs/tutorials/gtk4/examples/layout_center.py

raw
1 import gi
2
3 gi.require_version("Gtk", "4.0")
4 from gi.repository import Gtk
5
6
7 class CenterBoxWindow(Gtk.ApplicationWindow):
8 def __init__(self, **kargs):
9 super().__init__(**kargs, default_width=400, title="CenterBox Example")
10
11 box = Gtk.CenterBox()
12 self.set_child(box)
13
14 button1 = Gtk.Button(label="Start")
15 box.set_start_widget(button1)
16
17 label = Gtk.Label(label="Center")
18 box.set_center_widget(label)
19
20 button2 = Gtk.Button(label="End")
21 box.set_end_widget(button2)
22
23
24 def on_activate(app):
25 # Create window
26 win = CenterBoxWindow(application=app)
27 win.present()
28
29
30 app = Gtk.Application(application_id="com.example.App")
31 app.connect("activate", on_activate)
32
33 app.run(None)