From ff1cadbd80efa378a57d75eadccb0b1a3f470a28 Mon Sep 17 00:00:00 2001 From: cnmcdee Date: Tue, 1 Dec 2026 02:28:36 +0000 Subject: [PATCH] Phase 1 fixes: import cairo for the draw signal, Gdk version, hint wrap - canvas.py imports cairo so the draw signal marshalling works (needs python3-gi-cairo on the server; installed 3.56.2-1) - app.py: gi.require_version Gdk + hint label wraps in the palette pane - README: python3-gi-cairo is a required package --- README.md | 5 ++++- lightgui/app.py | 3 +++ lightgui/xframe/canvas.py | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a447412..3403c96 100644 --- a/README.md +++ b/README.md @@ -19,12 +19,15 @@ and https://github.com/cnmcdee/lightgui_rust (Rust port). - Python 3.10+ - PyGObject (`python3-gi`, GTK 3) - pycairo (`python3-cairo`) — the XFrame widgets draw with Cairo +- `python3-gi-cairo` — the PyGObject/Cairo bridge; without it the + canvas `draw` signal fails with "Couldn't find foreign struct + converter for 'cairo.Context'" - GTK 3.24 On Debian/Ubuntu/Parrot: ``` -sudo apt install python3-gi python3-cairo gir1.2-gtk-3.0 +sudo apt install python3-gi python3-cairo python3-gi-cairo gir1.2-gtk-3.0 ``` ## Run diff --git a/lightgui/app.py b/lightgui/app.py index 1a8071e..954f14b 100644 --- a/lightgui/app.py +++ b/lightgui/app.py @@ -9,6 +9,7 @@ on resize; there is no fixed 800x600 canvas. import gi gi.require_version("Gtk", "3.0") +gi.require_version("Gdk", "3.0") from gi.repository import Gdk, Gtk # noqa: E402 @@ -78,6 +79,8 @@ class Application: hint = Gtk.Label( label="Pick a widget, then click the canvas to place it.", xalign=0) + hint.set_line_wrap(True) + hint.set_max_width_chars(32) hint.set_margin_start(6) hint.set_margin_top(4) pane.pack_start(hint, False, False, 0) diff --git a/lightgui/xframe/canvas.py b/lightgui/xframe/canvas.py index b88d3cc..4bbcbbb 100644 --- a/lightgui/xframe/canvas.py +++ b/lightgui/xframe/canvas.py @@ -29,6 +29,8 @@ import gi gi.require_version("Gtk", "3.0") gi.require_version("Gdk", "3.0") +import cairo # noqa: F401 (registers the cairo.Context converter with gi) + from gi.repository import Gdk, Gtk # noqa: E402 from lightgui.model import Project # noqa: E402