crftwr/puikit on GitHub · craftware

PuiKit — capability-based Python UI framework for terminal and GUI

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.

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

Screenshots

The bundled demo catalog, running unchanged on the macOS GUI backend and in a terminal (curses backend).

macOS GUI backend Curses (terminal) backend
Widgets page of the demo catalog on the macOS GUI backend Widgets page of the demo catalog on the curses TUI backend
MarkdownView page of the demo catalog on the macOS GUI backend MarkdownView page of the demo catalog on the curses TUI backend
Modal confirm dialog with drop shadow and dimmed backdrop on the macOS GUI backend Modal confirm dialog with shadow and dimmed backdrop on the curses TUI backend

Apps built with PuiKit

Building something with PuiKit? Open an issue or PR to get it listed here.

Status

Stable release (1.0). Implemented:

Quick start

pip install puikit

That’s all you need — the base install ships a working TUI on every platform, and a native window on macOS (PyObjC installs automatically; on Windows the curses backport installs automatically). The minimal app below then runs as-is, with no repository checkout required.

Want to see it move right away? The hello-world example is a single self-contained file — download and run it without cloning the repo:

curl -O https://raw.githubusercontent.com/crftwr/puikit/main/examples/hello_world/main.py

python3 main.py                  # TUI — in a terminal, any platform
python3 main.py --backend gui    # native window — macOS
python3 main.py --backend web    # opens a browser tab — any platform

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)

Run it in a terminal for the TUI backend, or pass --backend gui (macOS) / --backend web (any platform) if you wire up argument handling like the bundled examples.

Development (from source)

Clone the repository, then install editable with the dev extras:

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

Contact & Support

License

See LICENSE.