Added basic GTK window handling

This commit is contained in:
Qubasa
2023-11-25 01:55:01 +01:00
parent d73236a62d
commit 0a7496835d
6 changed files with 225 additions and 17 deletions

View File

@@ -0,0 +1,61 @@
## Developing GTK3 Applications
Here we will document on how to develop GTK3 application UI in python. First we want to setup
an example code base to look into. In this case gnome-music.
## Setup gnome-music as code reference
gnome-music does not use glade
Clone gnome-music and check out the tag v40.0
[gnome-music](https://github.com/GNOME/gnome-music/tree/40.0)
```bash
git clone git@github.com:GNOME/gnome-music.git && cd gnome-music && git checkout 40.0
```
Checkout nixpkgs version `468cb5980b56d348979488a74a9b5de638400160` for the correct gnome-music devshell then execute:
```bash
nix develop /home/username/Projects/nixpkgs#gnome.gnome-music
```
Look into the file `gnome-music.in` which bootstraps the application.
## Setup gnu-cash as reference
Gnucash uses glade with complex UI
Setup gnucash
```bash
git clone git@github.com:Gnucash/gnucash.git
git checkout ed4921271c863c7f6e0c800e206b25ac6e9ba4da
cd nixpkgs
git checkout 015739d7bffa7da4e923978040a2f7cba6af3270
nix develop /home/username/Projects/nixpkgs#gnucash
mkdir build && cd build
cmake ..
cd ..
make
```
### Glade
Make sure to check the 'composit' box in glade in the GtkApplicationWindow to be able to
import the glade file through GTK template
## Links
- Another python glade project [syncthing-gtk](https://github.com/kozec/syncthing-gtk)
- Other python glade project [linuxcnc](https://github.com/podarok/linuxcnc/tree/master)
- Install [Glade UI Toolbuilder](https://gitlab.gnome.org/GNOME/glade)
- To understand GTK3 Components look into the [Python GTK3 Tutorial](https://python-gtk-3-tutorial.readthedocs.io/en/latest/search.html?q=ApplicationWindow&check_keywords=yes&area=default)
- Also look into [PyGObject](https://pygobject.readthedocs.io/en/latest/guide/gtk_template.html) to know more about threading and async etc.
- [GI Python API](https://lazka.github.io/pgi-docs/#Gtk-4.0/classes/ApplicationWindow.html#Gtk.ApplicationWindow)
- https://developer.gnome.org/documentation/tutorials/application.html