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; install with pip install -e ".[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.0.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.0-py3-none-any.whl (29.0 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: puikit-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 87e1b2c69c7a498a7d6150fcf1cefedeb94c2ff51a6770e8e82fd03b17f0f93c
MD5 5fcbb3c4328e9447ecbe7fc16ad9f943
BLAKE2b-256 6ce8749551e39aa1b230ea379224d91a981523c8ebaa8550ee145e7f4fd90b9e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: puikit-1.0.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e73cf55b8593a80fe9aff3907ea5ac1b4bbf0e63f08aaaa217410b271e4c55bc
MD5 21ee80f958fd1ec58537fd55d5a9e44c
BLAKE2b-256 77b8912a9739ed26159e2562d669b3df32840fe9d85c217a54f7c90772ec541a

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