OS image:
Debian GNU/Linux 12 (bookworm) aarch64 Linux raspberrypi 6.6.62+rpt-rpi-2712 SMP PREEMPT Debian 1:6.6.62-1+rpt1 (2024-11-25)
Ref:
- https://www.gtk.org/docs/language-bindings/python/
- https://pygobject.gnome.org/getting_started.html#ubuntu-getting-started
- https://python-gtk-3-tutorial.readthedocs.io/en/latest/
Setup:
sudo apt update
sudo apt install libopenblas-dev libblas-dev m4 cmake python3-dev python3-yaml python3-setuptools
sudo apt install python3-gi python3-gi-cairo gir1.2-gtk-4.0
sudo apt install at-spi2-core
sudo rm /usr/lib/python3.*/EXTERNALLY-MANAGED
sudo pip install cython
First Run:
Create new pyscript and,
import gi
gi.require_version("Gtk", "4.0")
from gi.repository import Gtk
def on_activate(app):
win = Gtk.ApplicationWindow(application=app)
btn = Gtk.Button(label="Hello, World!")
btn.connect('clicked', lambda x: win.close())
win.set_child(btn)
win.present()
app = Gtk.Application(application_id='org.gtk.Example')
app.connect('activate', on_activate)
app.run(None)