Skip to main content

Clack-style terminal UI primitives for prompt-first Python TUIs.

Project description

griphtui

Minimal and ergonomic Clack-style terminal UI primitives for Python CLIs/TUIs.

Install

uv add griphtui

The basics

GriphTUI is heavily inspired by Clack, and follows many of the same basic principles.

You'll probably want to begin with an intro:

import griphtui as gtui

gtui.intro("The grand survey")

...after which you can employ a range of primitives to prompt the user:

# section header
gtui.section("Let's talk about trains")

# text input
gtui.text("What's your favorite train?")

# select
gtui.select(
    "Can this train drift?",
    [("Probably", "probably"), ("Definitely", "definitely")]
)

# multiselect
gtui.select(
    "Which of the following applies to your favorite train?",
    [
        ("I wish it could drift", "wish", True), # toggled on by default
        ("I'm sad that it can't drift", "sadness", False)
        ("It's really nice that it can drift", "happiness", False)
    ]
)

# spinners
with gtui.spinner("Preparing for ethical dilemmas...") as s:
    time.sleep(1)
    s.update("Installing drift capabilities...")
    time.sleep(1)
    s.update("Updating Terms of Use...")

# status messages
gtui.warn("Aristoteles disliked this") # info, step, success, warn or error

Finally, wrap up with an outro:

gtui.outro("That's all, folks!")

There's a bit more available, eg. input validation. See the example if you want to dive deeper.

API

Function Purpose
intro(title) / outro(msg) / section(title) frames
text(label, default="") single-line input
password(label) masked input
confirm(label, default=True) y/n prompt
select(label, options) single-choice picker
multiselect(label, options) multi-choice picker
spinner(label) threaded spinner context manager
info / step / success / warn / error prefixed status lines

All prompts accept an optional console= kwarg if you want to inject your own Rich Console.

Platforms

Linux, macOS, and Windows (uses msvcrt for raw input on Windows, termios/tty elsewhere).

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

griphtui-0.1.4.tar.gz (27.4 kB view details)

Uploaded Source

Built Distribution

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

griphtui-0.1.4-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file griphtui-0.1.4.tar.gz.

File metadata

  • Download URL: griphtui-0.1.4.tar.gz
  • Upload date:
  • Size: 27.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for griphtui-0.1.4.tar.gz
Algorithm Hash digest
SHA256 cfd3b5e7153a23c654618999fb96dbc9e0f063a040ef4bb74d89666e87baf4f3
MD5 872c2d4d66147b8ba236db545870b7e3
BLAKE2b-256 231da07a593ff12ccd6b703759d29f5e7ac25e09330c70889f0ab1d49471894b

See more details on using hashes here.

Provenance

The following attestation bundles were made for griphtui-0.1.4.tar.gz:

Publisher: publish.yml on bhark/griphTUI

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

File details

Details for the file griphtui-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: griphtui-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for griphtui-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6396ac4b2bf28258204f4ea9c937ad764c06509e13a67a8131e756692b73a474
MD5 ea6684647c3a9068c0fcc8d0dac3e1d2
BLAKE2b-256 5d32e60643c4719c58d4dfbe8709fd4a82437a2c52af2808d81eab66505a8ceb

See more details on using hashes here.

Provenance

The following attestation bundles were made for griphtui-0.1.4-py3-none-any.whl:

Publisher: publish.yml on bhark/griphTUI

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