Quickstart

Install tuiify and create your first terminal form from a typed Python function.

Create a terminal form from a typed Python function and return its submitted result.

Install tuiify

  1. Use Python 3.9 or later.
  2. Install the package:
pip install tuiify

Create an interactive function

  1. Create a file named greet.py.
  2. Add a typed function and decorate it with @interactive:
from tuiify import interactive


@interactive
def greet(name: str, excited: bool = False) -> str:
    """Create a greeting."""
    suffix = "!" if excited else "."
    return f"Hello, {name}{suffix}"


if __name__ == "__main__":
    result = greet()
    print(result)
  1. Run the script:
python greet.py

A full-screen form opens with a text input for name and a checkbox for excited. Enter a name, then press Ctrl+S to submit.

After submitting Ada with excited selected, the app displays the result and the script prints:

Hello, Ada!

Call the function directly

Pass arguments when you want the original Python function to run without opening the form:

from tuiify import interactive


@interactive
def greet(name: str, excited: bool = False) -> str:
    suffix = "!" if excited else "."
    return f"Hello, {name}{suffix}"


print(greet("Ada", excited=True))

Expected output:

Hello, Ada!

Continue with input types to choose controls for your function parameters.


Did this page help you?