# 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). ## Status **All 7 phases complete** (Nov 30 – Dec 1, 2026). The designer runs under Xvfb and on a real display, with 363 tests passing (`DISPLAY=:99 python3 -m unittest discover -s tests`). See `docs/architecture.md` for the phase plan actually used and the final module layout. ![Designer main window with Inspector](screenshots/main-window.png) ![Code window with generated Python](screenshots/code-window.png) ![Debugger stopped at a breakpoint](screenshots/debugger-stopped.png) ## 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 562 separate widget classes. The C designer is the canonical reference for behaviour; the Rust port is the reference for structure. ## Requirements - Python 3.10+ (developed and verified against Python 3.14.4) - 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 (`gir1.2-gtk-3.0`) On Debian/Ubuntu/Parrot: ``` sudo apt install python3-gi python3-cairo python3-gi-cairo gir1.2-gtk-3.0 ``` No other dependencies: no build step, no compiled extensions, no package install needed to run from a checkout. ## Run ``` ./ide ``` `./ide` needs a display (`DISPLAY` set); under Xvfb, `DISPLAY=:99 ./ide`. The designer opens with the Object Inspector parked beside it. The Code window (holds the menu bar, code editor, and build console) opens with Ctrl+E or View → Code Window. ## What works - **Designer canvas** — 598-entry palette covering all 562 widget kinds; place by clicking, select, drag to move, resize handles (13px, double-click to show), Delete/Escape, status bar with selection geometry. - **Object Inspector** — geometry spins, generic + per-widget custom properties, Lazarus event names as editable handler text, font picker, bulk parameter (set all / selected / filtered, clear), 16-colour palette. Edits live-apply to the canvas; a programmatic resize refreshes just the geometry rows. - **Code view** — gutter outside the horizontal scroller, code folding, Monokai theme, tabs, Ctrl+S, dirty tracking. - **Codegen** — deterministic Python code generation from the placed widgets (anchors, events, model-only props as comments); generated scripts use the Python XFrame widgets. - **Project I/O** — `.fdj` place files load/save (byte-compatible with the C/Rust designers' format for the shared fields). - **Build / Run** — Build runs `python3` syntax-check + run on the generated script and shows the output in a filling, scrolling console; Run launches it. - **Debugger** — pdb-based step debugger in its own window: breakpoints (staged before start, live after), Run / Continue / Step Over / Step Into / Step Out, Stop, Restart, Settings (stop on entry, break on main), Locals, Watches, call stack, Hits column, debuggee output console. Step-over lands in the caller; breakpoint selection survives refreshes. - **Install Libraries** (Tools menu) — copies the `lightgui` package to the system site-packages, installs a `lightgui` launcher and a `.desktop` entry, so generated scripts run without `PYTHONPATH`. - **Stock (37) + Instrumentation (66) widgets** — drawn with Cairo and covered by data-driven property tables, including 14/16-segment displays. - **Monitor (15) widgets** — btop-style live system monitors (XHistoryGraph, XCoreGrid, XNetGraph, XTempHistory, XUsageBar, XStackBar, XVerticalBar, XTachometer, XArcGauge, XDonutGauge, XProcessList, XLoadBadge, XMonitorButton, XMonitorGrid, XSysBox), drawn with Cairo on dark panels. Sample data is runtime state only (deterministic demo data until push() / refresh() / poll() feeds real data); checks are stdlib only (/proc scan, `systemctl is-active`, localhost sockets). Examples in `examples/x*.py` run a GLib timer feeding live data; screenshots in `examples/shots/`. ## Layout ``` ide launcher (checks DISPLAY, runs python3 -m lightgui) 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 project_io.py .fdj load/save props.py property tables (generic set + per-widget), data-driven props_phase6.py Stock + Instrumentation property tables props_monitor.py Monitor (15) 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 (598 entries) stock.py Stock widgets (37) instruments.py Instrumentation widgets (66) monitor.py Monitor widgets (15) 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 design decisions, phase plan, final module layout stock-charts-data.md stock charts: data model, CSV format, set_series/load_csv API screenshots/ fresh Xvfb screenshots of the current UI ``` ## Tests ``` DISPLAY=:99 python3 -m unittest discover -s tests ``` Display-free logic tests run anywhere; the GTK widget tests are skipped without a display (run them under Xvfb, `:99` on the dev server). ## Known limits (honest) - **Install Libraries: real root-password prompt unverified on the server.** `pkexec` is not installed there, so the graphical root-password prompt cannot be completed live — only the prompt/piping/flow is verified, and the unit tests cover the dry-run path only (command construction, file list, target paths). No test performs a real privileged install. - **Debugger: no logpoint UI.** pdb has no dprintf equivalent, so there is no logpoint (print-without-stopping) breakpoint type. - **Debugger: a breakpoint on a `def` line fires at definition time.** That is pdb semantics: the breakpoint triggers when the `def` statement executes, not when the function is later called. Use "Break on main" or a breakpoint on the first line inside the function to stop on entry. - **Generated scripts need `lightgui` on `PYTHONPATH` unless installed system-wide.** The IDE's Run/Build flow and the debugger set `PYTHONPATH` to the repo checkout automatically; a generated script run by hand needs `PYTHONPATH=/path/to/lightgui_python` (or Tools → Install Libraries).