Muse 81a9693d71 Fix monitor-widget proportions: dynamic graph margins, scaled fonts, tach numerals
- Graphs (History/Net/Temp): dynamic left margin from the widest Y
  label (fixes Y labels overflowing the plot), legend on top, 5 Y
  labels, humanised units in NetGraph, TempHistory threshold label
  above the line ("80 C limit"), top/bottom Y labels hang clear of
  the title and the strip below the plot. History gains -60s/now.
- XTachometer: numerals 7.5% of dial diameter bold just inside the
  tick ring, RPM bold centred in-dial below the top numerals (its
  baseline hangs below the top numeral so it cannot collide with
  the 3200/4800 numerals on small dials), readout "value (peak N)"
  enlarged below the hub, redline numerals in red.
- All 14 audit widgets: font sizes derived from widget dimensions
  per the proportions audit (titles 16px bold, hero values 24-48px
  bold, body/legend 13-16px, min 11px); CoreGrid keeps 4x2; UsageBar
  labels outside the bar on a dark panel; StackBar title+total
  header (adaptive: omitted at 48px where it would push the legend
  out) with centred block; VerticalBar value inside the bar, peak
  label with shrink-to-fit; ArcGauge centre 40-48px + endpoints;
  DonutGauge centre 36-44px, ring 8-10% of diameter, duplicate
  title dropped, centre label is the value name; ProcessList 13px
  rows, bold header with sort indicator, "N procs"; LoadBadge
  centred two-line block with scaled values; MonitorButton scaled
  label/dot/status + detail line; MonitorGrid ceil(sqrt(n)) columns,
  name+status+detail design with wrapped detail; SysBox hero
  28-32px + max + bar %.
- New _fpx() clamp helper; XStackBar gains the "unit" prop
  (props_monitor.py) for its "total <sum> <unit>" header.
- Demos: button/grid labels "SSH :22" -> "sshd :22", tach label
  "Engine" -> "RPM", stackbar demo 320x48 -> 320x120 (title+bar+
  legend cannot fit in 48px), verticalbar demo 60 -> 160 wide
  (the "peak 82" label cannot fit in a 60px widget).
- Deviations from the audit spec: UsageBar label capped at 40px
  (the literal 0.45x rule gives 209px in a 464px-tall bar); SysBox
  hero uses 10% of height clamped 20-32px (spec 6-7% conflicts
  with the audited-correct PY value of 10.3%); PY LoadBadge gets
  no 1/5/15 sub-labels (the audit calls the PY layout correct;
  the sub-labels were directed at Rust).
Full suite: 363 tests OK (44 skipped). All 15 demos shot + verified.
2026-12-05 21:32:36 +00:00

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 Code window with generated Python Debugger stopped at a breakpoint

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).
S
Description
No description provided
Readme
2.4 MiB
0 Stars 1 Watchers 0 Forks
Languages
Python 99.9%