Skip to content

Getting Started

Install

The first step is to install Inquirer-Textual.

Inside a virtual environemnt, this library can be installed with:

pip install inquirer-textual

Or, if you're using the uv package manager:

uv add inquirer-textual

Single prompt

The prompt API is very straightforward, for example to get a text input:

from inquirer_textual import prompts

if __name__ == "__main__":
    name = prompts.text('Enter your name:')
    print(f'Hello, {name}! 👋')

Single prompt

Multiple prompts

By calling the prompt API multiple times, a form-like inquiry can be done:

from inquirer_textual import prompts

if __name__ == "__main__":
    first_name = prompts.text('First name:')
    last_name = prompts.text('Last name:')
    print(f'Hello, {first_name} {last_name}! 👋')

Multiple prompts

It's also possible to use a single multi prompt:

from inquirer_textual import prompts
from inquirer_textual.widgets.InquirerText import InquirerText

if __name__ == "__main__":
    answers = first_name = prompts.multi({
        'first_name': InquirerText('First name:'),
        'last_name': InquirerText('Last name:')
    })
    if answers.value is not None:
        print(f'Hello, {answers.value["first_name"]} {answers.value["last_name"]}! 👋')

multi prompt

Prompt settings

All prompts have a settings parameter of type PromptSettings. The following fields can be configured on this class:

clear

A boolean indicating whether to clear the prompt and result from the screen after an answer was submitted (True), or (False, default) leave the prompt and answer on the screen.

mandatory

A boolean indicating whether a prompt needs to be ansewered (True), or (False, default) a prompt can be skipped with ctrl+C and a None value is returned.

mouse

A boolean indicating whether mouse support is active (True), or (False, default) a mouse is not supported.