Post #2774205
2026-02-16 11:50 UTC
@javalps@mastodon.social If we look at an earlier version of Graphs (https://github.com/sstendahl/Graphs/tree/v1.5.0), after you defined your ui file. You create a window using this:
```
@Gtk.Template(resource_path="/se/sjoerd/Graphs/ui/window.ui")
class GraphsWindow(Adw.ApplicationWindow):
__gtype_name__ = "GraphsWindow"
undo_button = Gtk.Template.Child()
redo_button = Gtk.Template.Child()
item_list = Gtk.Template.Child()
sidebar_flap = Gtk.Template.Child()
pan_button = Gtk.Template.Child()
```
2/x
Replies (1)
-
@sstendahl@floss.social 2026-02-16 11:51
@javalps@mastodon.social Example was from window.py So Gtk.Template.Child() retrieves the widget from the ui file using the name you have on the left. To make the window show up, you need to create a window based on that class, and present it: ``` win = GraphsWindow(application=self) win.present() ``` See https://github.com/sstendahl/Graphs/blob/v1.5.0/src/main.py Note this is an earlier version of Graphs. The latest main branch is a much better example of "good code". But the project was also simpler back then, so probably easier to get.