Skip to main content

This project implements a keyboard-controlled text user interface (TUI) for the terminal that allows users to navigate menus and nested subsections using simple key inputs (w, s, Enter, Esc). It provides a lightweight framework for building interactive CLI applications with features like menu navigation, subsections, progress bars, and confirmation prompts.

Project description

from narwhals.utils import requiresfrom narwhals.utils import requires

py_menu_tui

py_menu_tui is a lightweight terminal user interface (TUI) navigation framework for Python.
It allows developers to quickly build interactive command-line menus with keyboard navigation and nested subsections.

The interface is controlled using simple keys and is designed for Windows terminals using msvcrt.


Features

  • Keyboard navigation (w / s)
  • Nested menu sections
  • Simple function binding to menu entries
  • Scrollable menus
  • Progress bar utility
  • Confirmation prompts
  • No external dependencies

Installation

Currently the package can be installed with:

pip install py_menu_tui

Controls

Key Action
w Move up
s Move down
Enter Select option
Esc Go back
Ctrl+C Exit program

Example

from py_menu_tui import UserInterface

def hello():
    print("Hello World")

ui = UserInterface()

ui.setup(
    ["Say Hello"],
    [hello]
)

ui.begin()

Creating Subsections

# Create a subsection
ui.add_sub_section(
    ["Option 1", "Option 2"],
    [func1, func2],
    section="Settings"
)

# Create a nested subsection inside "Settings"
ui.add_sub_section(
    ["Option 1", "Option 2"],
    [func1, func2],
    section="Audio",
    uppersection="Settings"
)

Utilities

#Progressbar
from py_menu_tui import progressbar
progressbar(50)

#Clear Terminal
from py_menu_tui import clear
clear()

#Confirmation Prompt
from py_menu_tui import confirm

if confirm("Continue?"):
    print("Confirmed")

#Wait for user input
ui.hold()

# Wait 5 seconds
ui.hold(time=5)

# Custom message and wait for input
ui.hold(msg="Press spacebar to continue")

Requirements

  • Python 3+
  • Windows terminal (uses msvcrt)
  • No external dependencies

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_menu_tui-0.2.6.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_menu_tui-0.2.6-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file py_menu_tui-0.2.6.tar.gz.

File metadata

  • Download URL: py_menu_tui-0.2.6.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for py_menu_tui-0.2.6.tar.gz
Algorithm Hash digest
SHA256 86d7064dbfa284be253e9789ca246e0f8b05484feddcb6f1b6af601befb0c6fc
MD5 ec64721fef98007003baa688aa3d0434
BLAKE2b-256 0ad40f32d396ac1f1e71db85b0c0582d31ba13d49b2bb224c5a0a6e1fafe7702

See more details on using hashes here.

File details

Details for the file py_menu_tui-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: py_menu_tui-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for py_menu_tui-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 8a22362b6cbd3abec68b88598f6f4c7af0bcefb81050851c5353f8eca5408713
MD5 5886feea3ef07b1d5e630b68b06fc684
BLAKE2b-256 ef9fa5105bf4088ca2b14e886a76a45cbcbf362d9a2666b18f0156708fc29aee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page