diff --git a/README.md b/README.md index 3403c96..64b2624 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,16 @@ 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 278 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). @@ -16,13 +26,13 @@ and https://github.com/cnmcdee/lightgui_rust (Rust port). ## Requirements -- Python 3.10+ +- 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 +- GTK 3.24 (`gir1.2-gtk-3.0`) On Debian/Ubuntu/Parrot: @@ -30,32 +40,67 @@ 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** — 583-entry palette covering all 547 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. + ## 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 - 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 + props_phase6.py Stock + Instrumentation property tables xframe/ - core.py XFrame core: widget base, registry, draw dispatch - canvas.py canvas (Gtk.DrawingArea), placement, selection, handles + 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) - 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 @@ -65,8 +110,36 @@ lightgui/ 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 +screenshots/ fresh Xvfb screenshots of the current UI ``` -## Status +## Tests -Port in progress. See `docs/architecture.md` for the port plan and per-phase status. +``` +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). diff --git a/docs/architecture.md b/docs/architecture.md index 8eb0504..93fa8c1 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -13,8 +13,9 @@ 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. + `crates/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 @@ -25,17 +26,106 @@ 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 +## Phase plan actually used -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. +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). -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). +0. **Skeleton + environment** (`e2ee6f8`) — repo on `main`, PyGObject/GTK IDE + chrome, XFrame-native canvas, runs under Xvfb. +1. **XFrame core + canvas + palette data** (`cef7988`, fixes `ff1cadb`) — + widget base/registry/draw dispatch, `CanvasState` (placement, selection, + handles, drag, double-click), 583-entry palette, project model. +2. **Generic widgets + property tables + live-apply** (`eeccee6`, `7717194`, + fix `5692908`) — property tables generated from C `props.h`, faithful + generic drawings, `Widget.set_prop` live-apply plumbing. +3. **Inspector + properties + font picker + bulk parameter** (`0cd61a3`, + fix `9383299`) — 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. +4. **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), `.fdj` load/save, build/run flow with a + filling scrolling console, menus in the Code window, dirty tracking. +5. **Debugger + Install Libraries** (`b6702c3`, follow-up `ba3b144`) — 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 + `.desktop` install). The eight documented C debugger bugs + are addressed in `debugger_ui.py` / `debugger.py` docstrings. +6. **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. +7. **Polish + verification + README + screenshots** (`6eabe93`, `c8263b2`, + …) — 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 a `def` line fires + at definition time per pdb; generated scripts need `lightgui` on + `PYTHONPATH` unless installed system-wide).