Simple CLI menu library for Python
Project description
cli-menu
Complete interactive CLI menu without external dependencies.
Description
cli-menu is a Python library to easily create interactive command-line menus, compatible with Windows, Linux, and macOS, with no external dependencies.
Features:
- Keyboard navigation (arrow keys up/down, left/right for paging)
- Single or multiple selection mode (space bar to check/uncheck)
- Quit with
qorESC - Colored display using ANSI codes
- Customizable titles and descriptions
- Automatic pagination
- Callbacks for specific options
- Windows and Unix compatible (handles console specifics)
Installation
pip install cli-menu
Basic Usage
from cli_menu import CliMenu
menu = CliMenu(
options=["Option 1", "Option 2", "Quit"],
title="=== MAIN MENU ===",
description="Use arrow keys and Enter to navigate.",
multiselect=False
)
choice = menu.show()
print(f"You selected: {menu.options[choice]}")
Main Parameters
| Parameter | Type | Description | Default |
|---|---|---|---|
| options | list[str] | List of options displayed in the menu | Required |
| title | str | Title displayed above the menu | None |
| description | str | Description displayed below the title | None |
| multiselect | bool | Enable multiple selection with space bar | False |
| page_size | int | Max number of options displayed per page | 10 |
| color | bool | Enable ANSI color output | True |
| exit_keys | list[str] | Keys to exit menu (e.g., q, ESC) |
['q', '\\x1b'] |
| callbacks | dict[int, func] | Functions triggered on option selection | {} |
Methods
show()
Displays the menu and handles keyboard interaction. Returns:
-
Selected index (int) in single-select mode
-
List of selected indices (list[int]) in multi-select mode
-
None if user exits with an exit key
Author
Gaetan Lerley -- Hostinfire@gmail.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters