Skip to main content

Python SDK for the rstui graphical terminal runtime

Project description

rstui

Python child SDK for the rstui graphical terminal runtime.

python3 -m pip install rstui
cargo install rstui
from rstui import Frame, run

def on_event(event, context):
    return "render" if event["type"] == "start" else "continue"

def render(context):
    width = context["geometry"]["pixel_width"]
    height = context["geometry"]["pixel_height"]
    return Frame(width, height, bytes(width * height * 4))

run(on_event, render)

Run the application with:

rstui run -- python3 app.py

stdout is reserved for the framed protocol. Write diagnostics to stderr.

Adaptive Matplotlib dashboard

Install the optional adapter and define only the grid, spans, and panel content:

python3 -m pip install 'rstui[matplotlib]'
from rstui import run
from rstui.matplotlib import Dashboard, Panel

def draw_chart(panel):
    axes = panel.axes()
    axes.plot([0, 1], [0, 1])

def draw_details(panel):
    axes = panel.axes()
    axes.set_axis_off()
    axes.text(0, 1, "Ready", va="top")

def on_event(event, context):
    return "render" if event["type"] in {"start", "resize"} else "continue"

page = Dashboard(
    columns=(2, 1),
    rows=(1,),
    panels=(
        Panel("chart", draw_chart, row=0, column=0, title="Chart"),
        Panel("details", draw_details, row=0, column=1, title="Details"),
    ),
)

run(on_event, page.render)

panel.axes() is already constrained to that panel. Full-screen pixels, terminal cells, resize, borders, titles, and framebuffer placement remain rstui responsibilities. Use Insets only when a chart needs extra panel-local room for tick labels.

Project: https://github.com/maokangkun/Terminal/tree/main/rstui

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

rstui-0.2.1.tar.gz (10.0 kB view details)

Uploaded Source

Built Distribution

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

rstui-0.2.1-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file rstui-0.2.1.tar.gz.

File metadata

  • Download URL: rstui-0.2.1.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rstui-0.2.1.tar.gz
Algorithm Hash digest
SHA256 c49fc2e105211b06afdc2c0440a770d18fe82c44fadedfe87074c5b3b3ec920d
MD5 872cfc4562c63b19bd4a3a0f47d7ef08
BLAKE2b-256 c4a134a59ccc571da864a89ace61507dc501dcb8663f21dd85d32957e9fca4e3

See more details on using hashes here.

File details

Details for the file rstui-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: rstui-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rstui-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f9acf48080981d3eed6569cb1e8629124e5f35519e5168203d90789dac58f7f1
MD5 070e0d253921fe82b45538ee8841e1f2
BLAKE2b-256 666baf3360f80321c95d0570d0869ef48d988d564cea63a118915a0116d43ad8

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