Featured image of post Python Libraries for Interactive CLI Console Menus

Python Libraries for Interactive CLI Console Menus

Review of command line menu systems for Python

If you’re tired of writing boring input() prompts and want to build interactive command-line menus that don’t feel like they’re from 1995, you’re in the right place.

Let’s be real—nobody wants to navigate through a 50-option menu by typing “Enter option 32” manually. Fortunately, Python has some amazing libraries that can handle interactive CLI menus without making you cry.


1. Prompt Toolkit (For Pros Who Like Fancy CLIs)

🛠 Best For: Developers who need powerful and flexible CLI interactions.
🖥 Works On: Windows, Linux, Mac
Key Features: Auto-completion, syntax highlighting, multi-line editing.

This library is the swiss army knife of interactive CLIs. It’s not just for menus—you can build full-on command-line applications.

Example:

1
2
3
4
from prompt_toolkit import prompt

user_input = prompt("Enter your name: ")
print(f"Hello, {user_input}!")

If you need autocomplete, syntax highlighting, and fancy text editing, Prompt Toolkit is your go-to. But if you’re just making a simple menu, it might be overkill.


2. PyInquirer (Inspired by Inquirer.js)

🛠 Best For: Developers who love pretty, structured CLI prompts.
🖥 Works On: Windows, Linux, Mac
Key Features: Lists, checkboxes, password input, validation.

Think of PyInquirer as the stylish, modern cousin of the old-school input() function. Inspired by Inquirer.js, it makes CLI menus look clean and interactive.

Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
from PyInquirer import prompt

questions = [
    {
        'type': 'list',
        'name': 'language',
        'message': 'Choose your favorite programming language:',
        'choices': ['Python', 'JavaScript', 'Go', 'Rust']
    }
]

answers = prompt(questions)
print(f"You chose {answers['language']}")

Unfortunately, PyInquirer hasn’t been updated in a while, but it still works fine. If you like it but want something maintained, check out questionary.


3. questionary (The Maintained PyInquirer Alternative)

🛠 Best For: Developers who need interactive prompts without outdated libraries.
🖥 Works On: Windows, Linux, Mac
Key Features: Multi-select, confirmation prompts, auto-complete.

This is basically PyInquirer but actively maintained. It offers all the same features, but you don’t have to worry about abandonware.

Example:

1
2
3
4
5
6
7
8
import questionary

choice = questionary.select(
    "What's your favorite framework?",
    choices=["Django", "Flask", "FastAPI", "None"]
).ask()

print(f"You chose: {choice}")

4. curses (For the Hardcore Terminal Nerds)

🛠 Best For: Developers who love old-school text-based UI applications.
🖥 Works On: Linux & Mac (Windows needs third-party libraries)
Key Features: Low-level terminal control, full-screen UI capabilities.

If you’re into retro terminal UI programming, curses is your best friend. But beware—this isn’t a simple menu library. It’s a full-on terminal UI toolkit.

Example:

1
2
3
4
5
6
7
8
import curses

def main(stdscr):
    stdscr.addstr("Hello, press any key to exit.")
    stdscr.refresh()
    stdscr.getch()

curses.wrapper(main)

Heads up: Windows doesn’t support curses natively. You’ll need windows-curses.


5. Click (For Building Full CLI Applications)

🛠 Best For: Developers building structured CLI tools with argument parsing.
🖥 Works On: Windows, Linux, Mac
Key Features: Command-line argument parsing, interactive prompts.

If your goal is not just a menu but a full-blown CLI application, Click is your best bet.

Example:

1
2
3
4
5
6
7
8
9
import click

@click.command()
@click.option('--name', prompt='What is your name?', help='Enter your name')
def greet(name):
    click.echo(f"Hello {name}!")

if __name__ == '__main__':
    greet()

Click is great for building serious CLI apps, but if you just need a simple interactive menu, it’s overkill.

🌈 Adding Colors and Styling

Want to add color to your CLI? Click has built-in support for ANSI colors.

1
2
3
4
5
6
7
8
9
@click.command()
def colorful():
    """Prints a colorful message"""
    click.secho("Success!", fg="green", bold=True)
    click.secho("Warning!", fg="yellow")
    click.secho("Error!", fg="red", blink=True)

if __name__ == '__main__':
    colorful()

6. Rich (For Fancy-Looking Menus)

🛠 Best For: Developers who want beautiful CLI menus with colors & formatting.
🖥 Works On: Windows, Linux, Mac
Key Features: Styled text, tables, markdown rendering.

If you want your CLI menu to look amazing, Rich is the way to go.

Example:

1
2
3
4
from rich.prompt import Prompt

name = Prompt.ask("Enter your name")
print(f"Hello, {name}!")

It doesn’t have built-in menus, but if you combine it with questionary, you get beautiful + interactive.


Comparison Table

LibraryBest ForWorks on Windows?Works on Linux?Complexity
Prompt ToolkitFull-fledged CLI applications✅ Yes✅ YesHigh
PyInquirerSimple interactive menus✅ Yes✅ YesMedium
questionaryMaintained alternative to PyInquirer✅ Yes✅ YesMedium
cursesTerminal UI apps❌ No*✅ YesHigh
ClickFull CLI applications✅ Yes✅ YesMedium
RichPretty-looking CLI menus✅ Yes✅ YesLow
  • curses requires windows-curses on Windows.

Final Thoughts

  • Need powerful CLI tools?Prompt Toolkit
  • Want simple interactive menus?questionary
  • Building a full CLI app?Click
  • Want your menus to look fancy?Rich

Use the right tool for the job, and your command-line menus will go from boring to awesome.


References

  1. Prompt Toolkit GitHub
  2. PyInquirer GitHub
  3. questionary GitHub
  4. Click Docs
  5. Rich GitHub