Phase 0 skeleton: PyGObject/GTK IDE chrome, XFrame-native canvas (Python port)

This commit is contained in:
cnmcdee committed 2026-12-01 02:16:44 +00:00
commit e2ee6f8bc3
7 files changed
+169

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
__pycache__/
*.py[cod]
*.egg-info/
.venv/
venv/
*.fdj.bak
+69
View File
@@ -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.
+41
View File
@@ -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).
Executable
+9
View File
@@ -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 "$@"
+3
View File
@@ -0,0 +1,3 @@
"""LightGUI designer — Python port (PyGObject/GTK chrome, XFrame-native canvas)."""
__version__ = "0.1.0"
+9
View File
@@ -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:]))
+32
View File
@@ -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()