Skip to main content

Production-grade Python bindings for ratatui 0.29 — the high-performance Rust TUI engine

Project description

pyratatui 🐀

Production-grade Python bindings for ratatui 0.29

Demo Image

Partnered by:
Alacritty Logo

CI PyPI Python 3.10+ License: MIT

pyratatui is a language bridge between Rust's high-performance terminal rendering engine and Python's ergonomic, productive ecosystem.

  • All rendering is native Rust via ratatui 0.29
  • Python gets a fully Pythonic API — fluent builders, snake_case, type stubs
  • Async readyAsyncTerminal integrates with asyncio seamlessly
  • Zero Rustisms in the public API
  • ABI3 wheels — one wheel per OS/arch, runs on Python 3.10–3.13+

Installation

pip install pyratatui

For building from source, you need Rust stable and maturin:

pip install maturin
maturin develop --release

Hello World

from pyratatui import Terminal, Paragraph, Block, Style, Color

with Terminal() as term:
    while True:
        def ui(frame):
            frame.render_widget(
                Paragraph.from_string("Hello, pyratatui! 🐀")
                    .block(Block().bordered().title("Demo"))
                    .style(Style().fg(Color.cyan())),
                frame.area,
            )
        term.draw(ui)
        ev = term.poll_event(timeout_ms=100)
        if ev and ev.code == "q":
            break

Layout + Widgets

from pyratatui import (
    Terminal, Layout, Constraint, Direction,
    Block, Paragraph, Gauge, List, ListItem, ListState,
    Table, Row, Cell, TableState,
    Style, Color, Text,
)

with Terminal() as term:
    list_state = ListState()
    list_state.select(0)
    table_state = TableState()
    table_state.select(0)

    while True:
        def ui(frame):
            # Split vertically: header | body | footer
            chunks = (Layout()
                .direction(Direction.Vertical)
                .constraints([
                    Constraint.length(3),
                    Constraint.fill(1),
                    Constraint.length(3),
                ])
                .split(frame.area))

            # Header
            frame.render_widget(
                Block().bordered().title("pyratatui Dashboard"),
                chunks[0],
            )

            # Body: split horizontally
            body = (Layout()
                .direction(Direction.Horizontal)
                .constraints([Constraint.percentage(40), Constraint.fill(1)])
                .split(chunks[1]))

            # Left: list
            items = [ListItem(f"Server {i+1}") for i in range(8)]
            frame.render_stateful_list(
                List(items)
                    .block(Block().bordered().title("Servers"))
                    .highlight_style(Style().fg(Color.yellow()).bold())
                    .highlight_symbol("▶ "),
                body[0],
                list_state,
            )

            # Right: table
            header = Row([Cell("Name"), Cell("CPU"), Cell("Mem")])
            rows   = [Row.from_strings(["nginx", "0.2%", "128MB"]),
                      Row.from_strings(["redis", "0.1%", "64MB"])]
            frame.render_stateful_table(
                Table(rows, [Constraint.fill(1)] * 3, header=header)
                    .block(Block().bordered().title("Processes"))
                    .highlight_style(Style().fg(Color.cyan())),
                body[1],
                table_state,
            )

            # Footer: gauge
            frame.render_widget(
                Gauge().percent(72).label("CPU: 72%")
                    .style(Style().fg(Color.green()))
                    .block(Block().bordered()),
                chunks[2],
            )

        term.draw(ui)
        ev = term.poll_event(timeout_ms=50)
        if ev:
            if ev.code == "q": break
            elif ev.code == "Down": list_state.select_next()
            elif ev.code == "Up":  list_state.select_previous()

Async Usage

import asyncio
from pyratatui import AsyncTerminal, Paragraph, Block, Style, Color

async def main():
    tick = 0
    async with AsyncTerminal() as term:
        async for ev in term.events(fps=30):
            def ui(frame, t=tick):
                frame.render_widget(
                    Paragraph.from_string(f"Tick: {t}")
                        .block(Block().bordered().title("Async"))
                        .style(Style().fg(Color.magenta())),
                    frame.area,
                )
            term.draw(ui)
            tick += 1

asyncio.run(main())

API Overview

Module Types
style Color, Modifier, Style
text Span, Line, Text
layout Rect, Constraint, Direction, Alignment, Layout
buffer Buffer
widgets Block, Paragraph, List, Table, Gauge, LineGauge, ...
terminal Terminal, Frame, KeyEvent
async AsyncTerminal, run_app, run_app_async
errors PyratatuiError, BackendError, LayoutError, RenderError, ...

Full API reference: https://pyratatui.github.io/pyratatui


Contributing

git clone https://github.com/pyratatui/pyratatui.git
cd pyratatui
python -m venv .venv && source .venv/bin/activate
pip install maturin pytest pytest-asyncio ruff mypy
maturin develop
pytest tests/python/
cargo test

License

MIT — see LICENSE.


Built with ratatui 🐀 and PyO3 🦀

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

pyratatui-0.1.0-cp310-abi3-win_amd64.whl (791.9 kB view details)

Uploaded CPython 3.10+Windows x86-64

pyratatui-0.1.0-cp310-abi3-manylinux_2_39_x86_64.whl (859.2 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.39+ x86-64

pyratatui-0.1.0-cp310-abi3-macosx_11_0_arm64.whl (804.5 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file pyratatui-0.1.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: pyratatui-0.1.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 791.9 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyratatui-0.1.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b7376a95c88be8328ba9241383793e1561770e58efb219562746f51bcaa69d12
MD5 2654edf42c881086c5c2109eac4d7eb9
BLAKE2b-256 74a2619785de0e7b146e89665e0684231f4f5e8a0297192475356a019ac34d0d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyratatui-0.1.0-cp310-abi3-win_amd64.whl:

Publisher: ci.yml on pyratatui/pyratatui

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyratatui-0.1.0-cp310-abi3-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for pyratatui-0.1.0-cp310-abi3-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 27c908757d13e9efb1ebd98a9dc9a1311c045692a643745afc462652499fca97
MD5 48eb71076e9de8bf4c13a99e67b7c993
BLAKE2b-256 f992ae99021fb557582ca6f69a5e1345feed91fb1e2351e1cf1ee4a75d9e217e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyratatui-0.1.0-cp310-abi3-manylinux_2_39_x86_64.whl:

Publisher: ci.yml on pyratatui/pyratatui

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyratatui-0.1.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyratatui-0.1.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 08f76eb04adc5ba97b0da7f51a309974df71a79ad649df4b8e7302d8bad2b29c
MD5 6f0a4b69ae6c18f0deb31a3d5bc432dc
BLAKE2b-256 03def7e53541c0302befbb385b5e37fb949bc63e0a645171d344387e7ece4fa5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyratatui-0.1.0-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: ci.yml on pyratatui/pyratatui

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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