Skip to main content

vir-tui

A lightweight, terminal UI primitive library for the VirInvictus CLI toolchain.

Provides a curses-based interactive menu with type-to-filter and mouse support, a scrollable results pager, ANSI colors with NO_COLOR and TTY gating, boxed input prompt lifecycles, theme overrides, and a session-aware progress box for CLI applications that run headless but offer an interactive terminal interface.

Used by CalibreQuarry and lattice-music for their full interactive sessions, and by bindery-cli for its formatters and the tqdm re-export.

Python · stdlib

Install

pip install vir-tui

Requires Python 3.14+: the package uses PEP 758 unparenthesized exception groups, which are a SyntaxError on older interpreters. There are no dependencies; when tqdm is installed it is re-exported, otherwise a minimal stub is provided.

Usage

import vir_tui

with vir_tui.interactive_session():  # owns the curses screen, or degrades to text
    while (choice := vir_tui.tui_select(
        "Library",
        [("Books", ["By title", "By author"]), ("Tools", ["Scan library", "Quit"])],
    )) not in ((1, 1), None):  # Quit, or q / Esc
        if choice == (1, 0):  # Tools > Scan library
            with vir_tui.progress_box(100, "Scanning") as bar:
                for _ in range(100):
                    bar.update()
        elif choice is not None:
            vir_tui.info(f"Picked {choice}")

Every widget degrades to plain text without curses or a TTY: menus become numbered typed lists, the pager prints, prompts read from stdin, and progress stays silent when piped.

Features

  • Menus: full-screen arrow-key tui_select (sections, aliases, letter keys) with an automatic numbered text fallback when curses is unavailable; a scrollable, pannable results pager (tui_page) with / search and n/N match jumping. aliases and letter_keys steer the numbered text fallback; inside curses, navigation is arrows, mouse, and the filter.
  • Filtering: on menus of 15+ entries, typing narrows the view incrementally (case-insensitive; backspace edits, Esc clears); small menus keep the classic single-key semantics.
  • Mouse: click moves the selection, double-click selects, and the wheel scrolls menus and pages; best-effort, degrading silently to keyboard-only.
  • Theming: configure_theme(color_pairs=..., glyphs=...) lets a host remap the six semantic color pairs and the box glyphs per app, instead of mirroring ids or forking widgets. Color pairs 1-6 are reserved: hosts drawing their own widgets use the public CP_* constants or ids 7+.
  • Progress: progress_box(), a session-screen-aware curses progress box with a tqdm-like API and a pipe-safe text fallback.
  • Sessions: interactive_session() context manager owning the curses screen lifecycle (open, degrade, close, KeyboardInterrupt cleanup).
  • Formatters: consistent success, info, warn, error styling across apps.
  • Prompts: ask, ask_yn, confirm, prompt_int, prompt_float, prompt_out, prompt_path, plus out_note for "where did my report go" footers.
  • Capture: run_with_capture wrapper for redirecting stdout/stderr into a temporary scrolling buffer while a background task runs, rendering a header/footer on top.

See API.md for the full exported surface and spec.md for the contract.

Support

If vir-tui's useful to you and you'd like to chip in:

License

GPL-3.0-or-later.

Metadata

Release files for vir-tui 2.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vir-tui 2.4.0
File Size Uploaded
vir_tui-2.4.0.tar.gz 51.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for vir-tui 2.4.0
File Interpreter ABI Platform
vir_tui-2.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 83.6 kB

Release files / vir_tui-2.4.0.tar.gz

Download URL vir_tui-2.4.0.tar.gz
Size 51.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3a5de6f9f6ef0c7a6e9fe63ad7c5ec90e0446141f851cb70a99a927ce4420fc6
BLAKE2b-256 checksum
How to use checksums
628befc95425629bc85df55d9beece83b5a2008a81f21091256cb9e11a5af11b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

Release files / vir_tui-2.4.0-py3-none-any.whl

Download URL vir_tui-2.4.0-py3-none-any.whl
Size 31.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b20bc24cedcee50e1b55af70cdcda9dc6055081c800a8f3d43541e839732e344
BLAKE2b-256 checksum
How to use checksums
e125387d68bb2098abc3db15f231a67ac631245f4e349c1e577338b2c7f17c7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

Release history Release notifications | RSS feed

2.5.0

2 release files

This release

2.4.0 This release

2 release files

2.3.0

2 release files

2.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page