python-ui-lord
Lord skill for Python UI design mastery — PySide6/Qt6 desktop apps, Textual 8 TUI, Flet 1.0 cross-platform, Reflex 0.9 / NiceGUI 3 / FastAPI+htmx web apps, design tokens, states, a11y, and packaging.
Files1
View on GitHubSKILL.mdskills/python-ui-lord/SKILL.md
GitHubPython UI Lord
[SKILL] python-ui-lord [OBJ] Design and ship #1-quality Python UIs across desktop, terminal, and web — correct framework selection, token-driven theming, complete state coverage, a11y, and production packaging. No slop, no wrong tool.
[RULES]
- [REQ] Framework Selection — Choose by deliverable, not habit. Matrix: professional native desktop/long-lived product → PySide6 6.10+; terminal/SSH/dev-ops tools → Textual 8; one Python codebase → desktop+web+mobile → Flet 1.0; production multi-user web app in pure Python → Reflex 0.9; fast custom web UI for tools/IoT/robotics → NiceGUI 3; server-rendered control → FastAPI+Jinja+htmx+Tailwind; batteries/admin → Django 6; data-science prototypes only → Streamlit/Dash/Gradio.
- [REQ] Licensing — Default PySide6 (LGPL, closed-source OK via dynamic wheels). PyQt6 is GPL/commercial — only with a purchased license or a GPL-compatible project.
- [REQ] Deprecation Watch — Never start new serious apps on customtkinter (dormant upstream, last release 5.2.2/2023) or Tkinter for anything beyond trivial scripts. Migrate path: PySide6 (native) or Flet (cross-platform).
- [REQ] Research-First — Before styling, pull real product references via the
design-researchskill (mobbin/refero MCP). ONE dominant design direction per app — never average references. No invented gradients. - [REQ] Context7 Gate — Query Context7 MCP for the chosen framework BEFORE writing implementation code; APIs drift (Flet 1.0 rewrote the event loop, NiceGUI 3 refactored scenes). Live docs > memory.
- [REQ] Tokens-First — Define the theme BEFORE the first widget: colors, spacing scale (4/8px base), type scale, radii, shadows. QSS template dict (Qt), .tcss theme (Textual),
page.theme(Flet),rx.theme(Reflex),ui.colors+Tailwind classes (NiceGUI), CSS custom properties (htmx path). Hardcoded hex in a widget = defect. - [REQ] One Icon Set — Pick one family per app (Lucide, Material Symbols, Iconsax) at one stroke weight;
qtawesome/flet.Icons/rx.iconmappings — never mix families. - [REQ] State Coverage — Every screen ships four states: empty (guidance + CTA, never bare "no data"), loading (skeleton/spinner, never blank), error (message + retry), success. Missing states = slop.
- [REQ] Feedback Latency — Every interaction gets visible feedback ≤100ms: hover, pressed, disabled, busy. Long ops show determinate progress or stream partial results.
- [REQ] Motion Discipline — 200–300ms transitions, ease-out on entry; animate transform/opacity only; honor reduced-motion/accessibility flags; never animate layout-blocking properties.
- [REQ] A11y — accessibleName/aria on all controls; full keyboard navigation + shortcuts (QShortcut/BINDINGS/accesskey); contrast ≥4.5:1 text, ≥3:1 UI boundaries; never color-only state; visible focus indicator.
- [REQ] Dark + Light — Ship both themes and verify each screen in both. Dark uses near-black surfaces (#0a0a0a–#1a1a2e range) with elevation tinting, never pure black.
- [REQ] Density & Grid — Align everything to the spacing scale; consistent paddings per surface tier (toolbar < content < footer); text columns ≤75 chars; resize windows/terminals to min target and re-verify.
- [REQ] RTL/Arabic —
Qt.LayoutDirection.RightToLeft/Textualtext-align/CSSdir="rtl"; logical properties; mirror nav/icons; Arabic font stack (IBM Plex Sans Arabic/Noto Sans Arabic, 1.5–1.7 line-height); test with real strings (+30% expansion). - [REQ] PySide6 Threading — NEVER touch QWidget/UI objects from a worker thread; QThreadPool+QRunnable with signals, or QThread+slots; heavy work yields progress via signals; use
@Slotdecorator. - [REQ] PySide6 Model/View — Data screens use QAbstractItemModel+QTableView/QSortFilterProxyModel (sorting/filtering for free); NEVER hand-populate QTableWidget for >100 rows — delegate+QListView/QML for cards.
- [REQ] PySide6 Theming — Keep the palette in ONE Python dict; generate QSS from a template (QSS has no variables); Fusion style base + QSS overrides;
QPalettefor platform-native fallbacks. - [REQ] PySide6 Product Shell — Standard chrome: menubar/toolbar/statusbar/QSystemTrayIcon; QSettings for geometry+splitters+theme; single-instance guard (QLocalServer/QLockFile); native QFileDialog; DPI-aware (Qt6 auto-scaling).
- [REQ] PySide6 Forms — Qt Designer
.uifor complex static forms →pyside6-uic; prefer code for dynamic UIs; NEVER hand-edit generatedui_*.py. - [REQ] Textual Architecture — App → Screen(s) → composed Widgets; styles in
.tcssfiles (not inline); reactive attrs +watch_/compute_for state; messages via@on/message handlers, not direct calls. - [REQ] Textual Async — NEVER block the message pump:
@work(thread=True)for CPU,run_worker/async for IO;LoadingIndicator/progress widgets during waits. - [REQ] Textual Tooling —
textual console+ devtools for live inspection; BINDINGS for every action; CommandPalette for discoverability;App.run_test()+pytest-textual-snapshotfor CI tests; same app can serve to browsers via textual-web for remote access. - [REQ] Flet 1.0 Model — Controls tree per
page; single event loop runs handlers (1.0 breaking change from 0.28 — don't mix old patterns);yield/page.update() semantics per docs;expand/spacing/alignmentfor responsive layout;Views +page.routefor navigation. - [REQ] Flet Theming & Targets —
page.theme=ft.Theme(color_scheme_seed=...)+page.dark_theme;page.theme_mode;flet buildtargets windows/macos/linux/web/apk/aab/ipa/ios-simulator; persistent services (Audio/Geolocator/Clipboard) survive reloads. - [REQ] Reflex Architecture —
rx.Statesubclasses hold ALL mutable state; event handlers mutate viaself; components subscribe to vars and re-render selectively; NEVER put business logic in components — backend functions/services behind events. - [REQ] Reflex Long Tasks —
@rx.event(background=True)for streaming progress/AI output (WebSocket push); yield intermediate state updates; NEVER block an event handler on long IO. - [REQ] Reflex Structure — Package layout:
pages/,components/,state/,backend/;rxconfig.pyfor app/db/tailwind config;rx.themetokens +class_nameTailwind escape;reflex run --env prodbehind granian for production. - [REQ] NiceGUI Discipline —
ui.*tree with slots;ui.dark_mode()binding;ui.timer/background async for live data;app.storage.user|clientfor persistence;ui.run(native=True)(pywebview) for a desktop window; escape to Quasar props via.props()/.classes()sparingly. - [REQ] htmx Path — FastAPI/Django + Jinja partials: endpoints return HTML fragments;
hx-target/hx-swapprecise swaps; CSRF on forms; Tailwind standalone CLI +@themetokens; followweb-design-guidelinesskill for the full 110-rule checklist. - [REQ] App Shell Contract — Title, icon, sane min/default window size, version string accessible; settings persist across restarts; proper shutdown (thread cleanup, port release, tray removal).
- [REQ] Data Screens — Sorting + filtering + search on every table; pagination or virtualized list >1k rows; column resize/reorder persistence via settings.
- [REQ] Dialogs & Feedback — Modal for destructive actions only; toast/snackbar for confirmations; validation inline at blur/submit with field-level errors; preserve user input on failure.
- [REQ] Packaging — Desktop: Nuitka preferred (smaller/faster) or PyInstaller; bundle Qt platforms plugin; native icon + version metadata; test artifact on a CLEAN machine/VM before delivery.
- [REQ] Testing — Smoke test "app boots to main screen" always; pytest-qt for Qt,
run_test()/snapshot for Textual, TestClient/Playwright for web paths; states (empty/loading/error) get dedicated tests. - [PROHIBIT] Never update UI from non-UI threads/processes — signals/events/messages only.
- [PROHIBIT] Never block the event loop or message pump — workers, async, or threads for all IO/CPU.
- [PROHIBIT] Never put business logic, SQL, or HTTP calls inside widgets/components — service layer behind the UI.
- [PROHIBIT] Never ship Streamlit/Dash as a production multi-user app — it's the prototype tier; production = Reflex/NiceGUI/FastAPI.
- [PROHIBIT] Never hardcode colors, spacing, or fonts outside the theme token system — no slop (generic gradients, placeholder text, default-styled widgets, mixed radii).
- [PROHIBIT] Never skip empty/loading/error states, keyboard nav, or the dark-mode pass.
- [PROHIBIT] Never assume versions/APIs — Flet 1.0 broke 0.28 handler semantics; NiceGUI 3 refactored
ui.scene; verify via Context7 + lockfile ([VER-01]). - [REQ] Desktop Security — secrets in OS keyring (
keyring→ Credential Manager/Keychain/libsecret), NEVER QSettings/.ini/plaintext; local UI servers (NiceGUI/Flet/webview modes) bind 127.0.0.1 + per-session auth token — open localhost API = any-process takeover; auto-updaters require signed packages + signature verification (unsigned updater = RCE); custom URL schemes/deep links validate every param (remote input);js_api/webview bridges expose Python methods — public API surface, validate + minimize; clipboard/drag-drop/file-drop content is untrusted. - [CMD] Context7 IDs —
/encode/httpxfamily for API calls inside apps; framework IDs: textual/textualize/textual, reflex/reflex-dev/reflex, nicegui/zauberzeug/nicegui, flet/flet-dev/flet, pyside6 (Qt for Python docs via/qt/qtforpythonwhen indexed — else official doc.qt.io). - [REQ] Delegation — Delegate pure HTML/CSS/token questions to
web-design-guidelines+ui-design-lord; research references viadesign-research; API contracts viaapi-architect; backend reflexes viabackend-design; security reviews viaweb-security-checklist+tech-stack/appsec-hardening.md.
[WORKFLOWS]
- New PySide6 desktop app — pick MVVM shape → define token dict + QSS template → shell window (menu/toolbar/status/tray) → screens with 4 states → Model/View for data → QThreadPool workers → QSettings persistence → a11y + RTL pass → smoke test → Nuitka/PyInstaller package → clean-VM verify.
- New Textual TUI — App + theme .tcss → screen map + BINDINGS → widgets with reactive state → workers for IO/CPU → CommandPalette → textual console devtools pass →
run_test()+ snapshot tests → optional textual-web serving. - New Reflex web app —
rxconfig.py→rx.themetokens →rx.Stateevent model → components/pages split → background events for long tasks → dark/light verify →reflex run --env prod→ deploy (self-host/Reflex Cloud). - FastAPI + htmx page — Jinja base (CSS custom props tokens + Tailwind) → partial endpoints → precise hx-swaps → CSRF + a11y per web-design-guidelines → pytest TestClient + Playwright smoke.