Metadata-Version: 2.4
Name: rstui
Version: 0.2.1
Summary: Python SDK for the rstui graphical terminal runtime
Project-URL: Homepage, https://github.com/maokangkun/Terminal/tree/main/rstui
Project-URL: Repository, https://github.com/maokangkun/Terminal
Project-URL: Issues, https://github.com/maokangkun/Terminal/issues
Author: maokangkun
License-Expression: Apache-2.0
License-File: LICENSE-APACHE
Keywords: graphics,rgba,sixel,terminal,tui
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Terminals
Requires-Python: >=3.10
Provides-Extra: matplotlib
Requires-Dist: matplotlib>=3.7; extra == 'matplotlib'
Description-Content-Type: text/markdown

# rstui

Python child SDK for the `rstui` graphical terminal runtime.

```sh
python3 -m pip install rstui
cargo install rstui
```

```python
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:

```sh
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:

```sh
python3 -m pip install 'rstui[matplotlib]'
```

```python
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
