Skip to main content

Capability-based Python UI framework with TUI and GUI backends

Project description

PuiKit

PuiKit is a capability-based Python UI framework that supports both TUI (terminal) and GUI (desktop, web) backends. Build apps and widgets once, run them on multiple backends without splitting implementations.

  • Apps and widgets specify what to draw (intent)
  • How to draw (implementation) is decided by the backend
  • Backends declare their capabilities; the Panel layer resolves fallbacks
  • Widget code never branches on TUI/GUI

See the documentation for design notes and per-system guides (layout, rendering, color, animation, fonts, widgets, and more).

Status

Stable release (1.0). Implemented:

  • Core framework: Panel, Backend interface, capability profiles, event model
  • Layout system: HSplit / VSplit / Item with weights and min_px / min hints — snapped to whole base units on TUI, resolved at pixel granularity on GUI
  • Animation: panel.animate(widget, hints={"transition": "fade", "duration_ms": 200}) — transitions fade (opacity), slide (position), scale (visual zoom), size (layout reflow), and highlight (color) rendered on the macOS backend; immediate switch on TUI
  • Widgets: Label, ListView, ScrollBar, Container
  • Widget tree: containers nest widgets with hierarchical clipping; animations on a parent cascade to all descendants, while children stay individually animatable
  • Backends:
    • CursesBackend — TUI, all platforms
    • MacOSBackend — macOS native GUI (PyObjC, installed automatically on macOS)
    • WindowsBackend — Windows native GUI (raw ctypes; Direct2D/DirectWrite)
    • WebBackend — runs in a web browser, launched with webbrowser over a local WebSocket (--backend web; see docs/web_backend.md)
    • MemoryBackend — headless, for tests
  • Planned next: C++ CoreText render extension

Quick start

python3.14 -m venv .venv
.venv/bin/pip install -e ".[dev]"

# Run the examples (in a terminal)
.venv/bin/python examples/hello_world/main.py
.venv/bin/python examples/demo_catalog/main.py

# On macOS, the same examples in a native window
.venv/bin/python examples/hello_world/main.py --backend gui
.venv/bin/python examples/demo_catalog/main.py --backend gui

# Or in a web browser (opens a tab; works on any platform)
.venv/bin/python examples/demo_catalog/main.py --backend web

# Run the tests
.venv/bin/python -m pytest

Minimal app

from puikit import EventType, Panel
from puikit.backends import create_backend
from puikit.widgets import Label

backend = create_backend("tui")
with backend:
    panel = Panel(backend)
    panel.add(Label("Hello, PuiKit!"), x=2, y=1, w=30, h=1)
    panel.render()

    def on_event(event):
        if event.type is EventType.KEY and event.key == "q":
            backend.quit()
            return
        panel.dispatch_event(event)
        panel.render()

    backend.run_event_loop(on_event)

License

See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

puikit-1.0.1.tar.gz (29.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

puikit-1.0.1-py3-none-any.whl (29.0 MB view details)

Uploaded Python 3

File details

Details for the file puikit-1.0.1.tar.gz.

File metadata

  • Download URL: puikit-1.0.1.tar.gz
  • Upload date:
  • Size: 29.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for puikit-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1e98bbca5cb10949024db2a43f90d3e5783f0af42f54ec574825bd242e0789b6
MD5 e0509f3c490bc6b72719d470c4d3f197
BLAKE2b-256 ec7ade6924c79d0cd8a60029149f2d1cb7b3d230451d1ce54d9a29dc7009425e

See more details on using hashes here.

File details

Details for the file puikit-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: puikit-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 29.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for puikit-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0182f127dc2ee894fa55f68d474cc35221a2abb843c19f2d189d9d0cc621fa5e
MD5 441cffe6e8efacb257271225847d2db9
BLAKE2b-256 e2dba5bc3b1106dd77f70e4e550d71851e6c60fff350dda7a481f342050cfaf8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page