Skip to main content

FlexMenu

Python Version License Version Download

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 top
  • options (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 msvcrt for keyboard input
  • Linux/macOS: Uses termios and tty for 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

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)

Source distribution for FlexMenu 1.0.0
File Size Uploaded
flexmenu-1.0.0.tar.gz 4.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for FlexMenu 1.0.0
File Interpreter ABI Platform
flexmenu-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.5 kB

Release files / flexmenu-1.0.0.tar.gz

Download URL flexmenu-1.0.0.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2be37bcbee9855ab601f4f384bc5a99b25418fef6a1f9c0e287d79c11bcd799d
BLAKE2b-256 checksum
How to use checksums
95c04780954dce893dc74db69c55f0d06426527b26d4b0ec7867525f6c7ee343
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.12.0 Windows/11

Release files / flexmenu-1.0.0-py3-none-any.whl

Download URL flexmenu-1.0.0-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
19db500febfdf2923d1911fcc5d5bdc2a30d153a418086f6d415f20a7609f15f
BLAKE2b-256 checksum
How to use checksums
54a3a4934b475d57a0ea5b41b4be70db36f8e7f96e2a15a12486f21a120ee6fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.12.0 Windows/11

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page