From e2ee6f8bc34ef3a13f323d01c900240b53dc6849 Mon Sep 17 00:00:00 2001 From: cnmcdee Date: Tue, 1 Dec 2026 02:16:44 +0000 Subject: [PATCH] Phase 0 skeleton: PyGObject/GTK IDE chrome, XFrame-native canvas (Python port) --- .gitignore | 6 ++++ README.md | 69 ++++++++++++++++++++++++++++++++++++++++++++ docs/architecture.md | 41 ++++++++++++++++++++++++++ ide | 9 ++++++ lightgui/__init__.py | 3 ++ lightgui/__main__.py | 9 ++++++ lightgui/app.py | 32 ++++++++++++++++++++ 7 files changed, 169 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 docs/architecture.md create mode 100755 ide create mode 100644 lightgui/__init__.py create mode 100644 lightgui/__main__.py create mode 100644 lightgui/app.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..64de173 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +__pycache__/ +*.py[cod] +*.egg-info/ +.venv/ +venv/ +*.fdj.bak diff --git a/README.md b/README.md new file mode 100644 index 0000000..a447412 --- /dev/null +++ b/README.md @@ -0,0 +1,69 @@ +# LightGUI — Python port + +A Python port of the LightGUI GUI designer: https://github.com/cnmcdee/lightgui (C++/GTK) +and https://github.com/cnmcdee/lightgui_rust (Rust port). + +## Architecture (decided by the user) + +- **IDE chrome in GTK via PyGObject** (menus, palette, canvas frame, Inspector, code view, dialogs). +- **All widgets home-brewed XFrame in Python** — the same architecture as the C and Rust + designers: GTK is chrome only, the canvas is XFrame-native. +- **Generated code is Python** using the Python XFrame widgets (the mirror of the C++ codegen). +- **Widget model follows the Rust port's archetype approach**: a small set of archetype + classes parameterised by a `kind` string, with data-driven property tables — not 547 + separate widget classes. The C designer is the canonical reference for behaviour; + the Rust port is the reference for structure. + +## Requirements + +- Python 3.10+ +- PyGObject (`python3-gi`, GTK 3) +- pycairo (`python3-cairo`) — the XFrame widgets draw with Cairo +- GTK 3.24 + +On Debian/Ubuntu/Parrot: + +``` +sudo apt install python3-gi python3-cairo gir1.2-gtk-3.0 +``` + +## Run + +``` +./ide +``` + +## Layout + +``` +lightgui/ + __init__.py version + __main__.py entry point + app.py Application, main window assembly (IDE chrome) + model.py project model: placed widgets, selection, .fdj place file + theme.py IDE theme (designer chrome only, not the generated app) + preferences.py preferences + project_io.py .fdj load/save + props.py property tables (generic set + per-widget), data-driven + xframe/ + core.py XFrame core: widget base, registry, draw dispatch + canvas.py canvas (Gtk.DrawingArea), placement, selection, handles + palette.py palette data (583 entries) + archetypes.py archetype widget classes (button, entry, label, ...) + widgets.py generic widget draw implementations + drawings.py shared drawing helpers (from C drawings.h) + indicators.py indicator drawing (from C indicators.h) + stock.py Stock widgets (37) + instruments.py Instrumentation widgets (66) + inspector.py Object Inspector window + codeview.py code view with gutter/folding + generator.py Python codegen + debugger.py pdb-based step debugger session + debugger_ui.py debugger UI + build.py run/build flow for Python apps (replaces CMake build) + install_libs.py Install Libraries flow (system-wide install, root prompt) +``` + +## Status + +Port in progress. See `docs/architecture.md` for the port plan and per-phase status. diff --git a/docs/architecture.md b/docs/architecture.md new file mode 100644 index 0000000..8eb0504 --- /dev/null +++ b/docs/architecture.md @@ -0,0 +1,41 @@ +# LightGUI Python port — architecture notes + +## Sources + +- C designer (canonical behaviour): /opt/lightgui, https://github.com/cnmcdee/lightgui +- Rust designer (structural reference): /opt/lightgui_rust, https://github.com/cnmcdee/lightgui_rust +- Property model: /root/lightgui-inspector-properties.md on the server + (Lazarus RTTI audit; generic set + per-widget custom props + 13 §4 flag decisions) + +## Key design decisions + +- **Widget model = Rust archetypes, not C's 547 headers.** A small set of archetype + classes parameterised by `kind`, with data-driven property tables. The C property + tables live in `src/props.h` and `tools/gen_phase4_props.py`; the Rust tables in + `crates/lightgui-core/src/props.rs` (4239 lines) and + `crates/xframe-indicators/src/generated.rs`. The Python tables should be generated + or transcribed from those, not re-invented. +- **Canvas**: Gtk.DrawingArea + Cairo. XFrame widgets draw themselves with Cairo; + the canvas handles placement, selection, handles (13px), drag, and double-click. +- **Generated apps are Python scripts** using the Python XFrame widgets. There is no + CMake build for them: the Build/Run flow runs `python3` on the generated script + (syntax check + run), and the build console shows that output. +- **Debugger**: the C debugger is GDB/MI over C++ apps. The Python equivalent drives + `pdb` in a subprocess over the generated Python script, mirroring the session + architecture (breakpoints, step in/out/over, watch, call stack). +- **Setters are state-only; the host redraws** (same convention as C/Rust). +- **Theme is for the layout designer only.** The generated app has its own properties. + +## Phase plan + +0. Skeleton + environment (this commit) — repo on `main`, runs under Xvfb. +1. XFrame core + canvas + palette data. +2. Generic widgets (archetypes) + property tables + live-apply plumbing. +3. Inspector + properties + font picker + bulk parameter. +4. Code view (gutter/folding) + codegen + project I/O (.fdj) + build/run. +5. Debugger (pdb session + UI) + Install Libraries. +6. Stock (37) + Instrumentation (66) widgets + property tables. +7. Tests + verification + README + screenshots. + +Phases are verified live under Xvfb with screenshots before the next starts. +Each phase commits + pushes its piece as it lands (remote HEAD == local HEAD). diff --git a/ide b/ide new file mode 100755 index 0000000..5d489f1 --- /dev/null +++ b/ide @@ -0,0 +1,9 @@ +#!/bin/sh +# LightGUI Python port launcher. Mirrors the C `ide` script: checks DISPLAY, +# then runs the designer. +if [ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ]; then + echo "ide: no display (DISPLAY unset)" >&2 + exit 1 +fi +cd "$(dirname "$0")" || exit 1 +exec python3 -m lightgui "$@" diff --git a/lightgui/__init__.py b/lightgui/__init__.py new file mode 100644 index 0000000..62fa99a --- /dev/null +++ b/lightgui/__init__.py @@ -0,0 +1,3 @@ +"""LightGUI designer — Python port (PyGObject/GTK chrome, XFrame-native canvas).""" + +__version__ = "0.1.0" diff --git a/lightgui/__main__.py b/lightgui/__main__.py new file mode 100644 index 0000000..bc501fe --- /dev/null +++ b/lightgui/__main__.py @@ -0,0 +1,9 @@ +"""Entry point: python3 -m lightgui""" + +import sys + +from lightgui.app import main + + +if __name__ == "__main__": + sys.exit(main(sys.argv[1:])) diff --git a/lightgui/app.py b/lightgui/app.py new file mode 100644 index 0000000..27bc546 --- /dev/null +++ b/lightgui/app.py @@ -0,0 +1,32 @@ +"""Application bootstrap and main window assembly (IDE chrome). + +Phase 0 skeleton: opens the main designer window. The canvas, palette, +Inspector and code view are wired in by later phases. +""" + +import gi + +gi.require_version("Gtk", "3.0") + +from gi.repository import Gtk + +from lightgui import __version__ + + +class Application: + def __init__(self): + self.window = Gtk.Window(title="LightGUI — Python/GTK") + self.window.set_default_size(1280, 800) + self.window.connect("destroy", Gtk.main_quit) + label = Gtk.Label(label=f"LightGUI Python port {__version__} — skeleton") + self.window.add(label) + + def run(self): + self.window.show_all() + Gtk.main() + return 0 + + +def main(argv): + app = Application() + return app.run()