Registry / devops / simple-term-menu

simple-term-menu

JSON →
library1.6.6pypypi✓ verified 23d ago

simple-term-menu is a Python package that facilitates the creation of interactive command-line menus. It enables users to select options using arrow keys, j/k (Vim motions), or emacs keys. The library intelligently adapts to terminal capabilities by leveraging the terminfo database, disabling unavailable styles. It is actively maintained, with frequent minor releases, and primarily supports Linux and macOS environments.

pip install simple-term-menu
INSTALL
IMPORT
SIG · SIMPLE-TERM-MENU
S
simple-term-menu
devopspythonv1.6.6
Install
1.5s avg
Import
52ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.6.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.050s · 18MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.5s · import 0.054s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

TerminalMenu
from simple_term_menu import TerminalMenu

This quickstart demonstrates how to create a basic terminal menu with a list of options. The `TerminalMenu` class is instantiated with the options, and the `show()` method displays the menu and returns the index of the selected item or `None` if cancelled.

from simple_term_menu import TerminalMenu def main(): options = ["entry 1", "entry 2", "entry 3"] terminal_menu = TerminalMenu(options) menu_entry_index = terminal_menu.show() if menu_entry_index is not None: print(f"You have selected {options[menu_entry_index]}!") else: print("Menu cancelled.") if __name__ == "__main__": main()
Debug
Known issues
breakingWhen upgrading from version 0.x to 1.x, the `TerminalMenu` constructor arguments (except the first parameter for menu entries) became keyword-only. This change was implemented to improve maintainability and allow for easier addition of new parameters.
fix
Update `TerminalMenu` constructor calls to use keyword arguments for all parameters except the initial list of options.
affects: 0.x -> 1.x
breakingBetween versions 1.1 and 1.2, the `multi_select_key` parameter was renamed to `multi_select_keys` and now expects an iterable of keys. Additionally, `shortcut_parentheses_highlight_style` was renamed to `shortcut_brackets_highlight_style` for consistency.
fix
Rename `multi_select_key` to `multi_select_keys` and pass an iterable. Rename `shortcut_parentheses_highlight_style` to `shortcut_brackets_highlight_style`.
affects: 1.1 -> 1.2
gotchasimple-term-menu is primarily designed for Unix-like systems (Linux, macOS) and relies on the `terminfo` database. It may not function correctly or provide a consistent experience on Windows due to fundamental differences in terminal capabilities.
fix
Consider alternative libraries for Windows-specific CLI menus or ensure a compatible terminal environment (e.g., WSL) is used.
affects: All versions on Windows
gotchaEmbedding extensive logic directly within conditional statements for each menu selection can lead to verbose and difficult-to-manage code, especially with many menu options or submenus.
fix
Refactor menu handling by using classes, dictionaries mapping options to functions, or other structured approaches to keep the code DRY and maintainable.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'simple_term_menu'
The 'simple-term-menu' package is not installed or not available in the current Python environment.
fix
pip install simple-term-menu
simple_term_menu.exceptions.UnsupportedTerminal: Failed to retrieve terminal capabilities.
The library could not determine the capabilities of the current terminal, often due to an unset TERM environment variable, a minimal terminal, or an unsupported environment like some Windows console setups.
fix
Ensure your TERM environment variable is set correctly (e.g., `xterm`, `screen`), or run the script in a more feature-rich terminal emulator. For Windows, consider using WSL or a compatible terminal.
TypeError: 'str' object is not iterable
The `menu_entries` parameter of `SimpleTermMenu` expects an iterable (like a list or tuple) of strings, but a single string was provided directly.
fix
Wrap the single string (or multiple strings) in a list: `SimpleTermMenu(menu_entries=['Option 1', 'Option 2'])`
AttributeError: 'SimpleTermMenu' object has no attribute 'display'
Attempting to call a non-existent method on the `SimpleTermMenu` object; the correct method to show the menu is `show()`.
fix
Use the correct method name `show()`: `selected_entry = menu.show()`
TypeError: TerminalMenu.__init__() got an unexpected keyword argument 'menu_title'
An incorrect or misspelled keyword argument (e.g., 'menu_title' instead of 'title') was passed to the TerminalMenu constructor.
fix
Use the correct parameter names as specified in the library's documentation, such as `title`, `menu_cursor`, or `cycle_cursor`.
Upgrade
Version history
1.6.6latest on PyPI · released Dec 2, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
19 hits · last 30 days
node
16
Amazon
1
Resources
simple-term-menu — pip install simple-term-menu · libregistry