FlexMenu
A lightweight, cross-platform terminal menu library for Python that enables keyboard-controlled menu selection with a clean visual interface.
Features
- Keyboard Navigation: Use ↑/↓ arrows to navigate, Enter/Space to select, ESC to cancel
- Cross-Platform: Works on Windows (msvcrt) and Unix/Linux/macOS (termios)
- Visual Feedback: Color-coded selection highlighting and clear operation prompts
- No Dependencies: Pure Python implementation using ANSI escape codes
- Lightweight: Simple and easy to integrate into any CLI application
Installation
Simply copy the FlexMenu class into your project. No additional dependencies required.
Quick Start
from FlexMenu import FlexMenu
# Create a menu
menu = FlexMenu("Main Menu", ["Start Game", "Settings", "Exit"])
# Run the menu
choice_index = menu.run()
# Get the selected option
if choice_index != -1: # -1 means user pressed ESC
print(f"You selected: {menu.get_choice}")
else:
print("Menu cancelled")
API Reference
FlexMenu(title, options)
Create a new menu instance.
title(str): The menu title displayed at the topoptions(list): List of option strings to display
Methods
run(): Display the menu and handle user input. Returns the index of selected option (0-based) or -1 if cancelled.get_choice(property): Returns the text of the currently selected option
Keyboard Controls
- ↑ / ↓: Navigate through options
- Enter / Space: Confirm selection
- ESC: Cancel and exit menu
Platform Support
- Windows: Uses
msvcrtfor keyboard input - Linux/macOS: Uses
termiosandttyfor keyboard input - Falls back to simple input mode if terminal control libraries are unavailable
Example
menu = FlexMenu(
"Configuration",
["Network Settings", "Display Options", "Audio", "Save & Exit"]
)
choice = menu.run()
if choice == 0:
configure_network()
elif choice == 1:
configure_display()
# ... etc
Metadata
Release files for FlexMenu 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flexmenu-1.0.0.tar.gz | 4.0 kB | Without provenance | Details for flexmenu-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flexmenu-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for flexmenu-1.0.0-py3-none-any.whl |
Total release size: 8.5 kB
Security for FlexMenu 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.