7.2 KiB
7.2 KiB
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 insrc/props.handtools/gen_phase4_props.py; the Rust tables incrates/lightgui-core/src/props.rs(4239 lines) andcrates/xframe-indicators/src/generated.rs. The Python tables were generated or transcribed from those, not re-invented (tools/gen_props.py,tools/gen_props_phase6.py). - 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
python3on 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
pdbin 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.
- Inspector refreshes are split by cause. Selection changes rebuild the rows
(
CanvasState.on_selection_change→Inspector.refresh); a bounds change under the same selection only re-syncs the four geometry spins (CanvasState.on_bounds_change→Inspector.refresh_geometry, Phase 7), so a programmatic resize is reflected without rebuilding rows or stealing focus while typing. Handle drags fire the same bounds hook.
Phase plan actually used
All phases landed Nov 30 – Dec 1, 2026, each verified live under Xvfb with
screenshots before the next started, each committed + pushed as it landed
(remote refs/heads/main == local HEAD).
- Skeleton + environment (
e2ee6f8) — repo onmain, PyGObject/GTK IDE chrome, XFrame-native canvas, runs under Xvfb. - XFrame core + canvas + palette data (
cef7988, fixesff1cadb) — widget base/registry/draw dispatch,CanvasState(placement, selection, handles, drag, double-click), 583-entry palette, project model. - Generic widgets + property tables + live-apply (
eeccee6,7717194, fix5692908) — property tables generated from Cprops.h, faithful generic drawings,Widget.set_proplive-apply plumbing. - Inspector + properties + font picker + bulk parameter (
0cd61a3, fix9383299) — Object Inspector window, geometry spins, generic + custom props, Lazarus events as editable text, font picker button, bulk set/clear, colour palette; rows expand to panel width. - Code view + codegen + project I/O + build/run (
caaebd9,9c52f53,45037b2,12ac322,b2ea94c,2a99acb,c22ff10) — deterministic Python codegen, code view (gutter outside the scroller, folding, Monokai, tabs, Ctrl+S),.fdjload/save, build/run flow with a filling scrolling console, menus in the Code window, dirty tracking. - Debugger + Install Libraries (
b6702c3, follow-upba3b144) — pdb session + debugger window (breakpoints, step in/out/over, watches, locals, stack, output console), step-over lands in the caller, Hits column syncs; Install Libraries (pkexec/sudo root prompt, package + launcher +.desktopinstall). The eight documented C debugger bugs are addressed indebugger_ui.py/debugger.pydocstrings. - Stock (37) + Instrumentation (66) widgets (
4333f72,11c380d,6d2dae2) — drawing + property tables, 103-kind table tests, draw smoke tests, anchor + short-plot guards, 14/16-segment maps and geometry verbatim from C. - Polish + verification + README + screenshots (
6eabe93,c8263b2,7513673,4f1e907(plus this file's final touch-up)) — debugger pane labels moved above their lists (the bottom-placed "Breakpoints" label had crowded the "Output" label); Inspector geometry rows refresh on programmatic resize via a bounds-change hook; README + this file brought up to date; fresh screenshots; fresh-clone install check; full test suite + every window verified under Xvfb.
Final module layout
ide launcher (checks DISPLAY, runs python3 -m lightgui)
lightgui/
__init__.py version (0.1.0)
__main__.py entry point
app.py Application, main window assembly (IDE chrome)
model.py project model: placed widgets, selection, .fdj place file
project_io.py .fdj load/save
props.py property tables (generic set + per-widget), data-driven
props_phase6.py Stock + Instrumentation property tables
xframe/
core.py XFrame core: widget base, registry, draw dispatch,
archetype draw implementations
canvas.py canvas (Gtk.DrawingArea), placement, selection, handles,
drag, double-click, bounds-change hook
palette.py palette data (583 entries)
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)
tests/ unittest suites, one file per module area
tools/ property-table generators (gen_props.py, gen_props_phase6.py)
docs/
architecture.md this file
screenshots/ fresh Xvfb screenshots of the current UI
Notes on the layout as built (vs the Phase 0 sketch): there is no separate
theme.py / preferences.py — the code-view theme lives in codeview.py
and there is no preferences dialog; archetype draw implementations live in
xframe/core.py rather than separate archetypes.py / widgets.py /
drawings.py / indicators.py files.
Final state
- All 7 phases complete; 278 tests passing under Xvfb (
DISPLAY=:99 python3 -m unittest discover -s tests), 0 failures. - Every window verified rendering under Xvfb: designer + Inspector, Code
window with generated Python, debugger stopped at a breakpoint,
Install Libraries dialog. Fresh screenshots in
screenshots/. - Fresh-clone check: a clean checkout to a scratch directory runs the full suite and launches the designer under Xvfb with nothing hidden in the working tree.
- Known limits are listed honestly in
README.md(Install Libraries root prompt unverified — no pkexec on the server; no debugger logpoint UI — pdb has no dprintf; breakpoint on adefline fires at definition time per pdb; generated scripts needlightguionPYTHONPATHunless installed system-wide).