Skip to main content

GRmenu

Menús de navegación por teclado para terminal, en modo TTY crudo

Flechas arriba/abajo para moverte · Enter para elegir · q para salir

PyPI version Python versions PyPI downloads License: MIT Publish to PyPI GitHub last commit GitHub stars


✨ Características

  • 🎮 Navegación con flechas — arriba/abajo para moverte, Enter para ejecutar, q para salir
  • 🎨 20 estilos de borde — desde ASCII clásico hasta caracteres Unicode y emoji-like
  • 🌈 Colores personalizables — borde, opciones y foco por separado, con 8 colores en 2 tonos cada uno
  • 📦 Cero dependencias externas — solo la librería estándar de Python (termios, tty, os)
  • 🐍 Ligero — un único archivo, fácil de auditar y de vendorizar si hace falta
  • 🐧 Linux / macOS — funciona en cualquier terminal POSIX

⚠️ Requiere una terminal real (TTY) en Linux o macOS. No funciona en Windows ni en streams no interactivos, porque usa los módulos termios/tty para leer teclas en modo crudo.


📦 Instalación

pip install grmenu

Requiere Python ≥ 3.9.


🚀 Uso rápido

from GRmenu import GRmenu

def opcion_uno():
    print("elegiste uno")

def opcion_dos():
    print("elegiste dos")

menu = GRmenu([opcion_uno, opcion_dos], title="Mi menu", style=19)
menu.SetStyle.Border("yellow")
menu.SetStyle.Options("green")
menu.draw()

Cada elemento de la lista es una función; el nombre de la función se usa como texto de la opción, y al presionar Enter sobre ella, esa función se ejecuta.


🕹️ Controles

Tecla Acción
Mover selección arriba
Mover selección abajo
Enter Ejecutar opción seleccionada
q Salir del menú

🎨 Personalización

Colores (SetStyle)

Cada zona del menú se personaliza por separado. level=1 es el tono normal y level=2 el brillante.

menu.SetStyle.Border("cyan")        # color del borde
menu.SetStyle.Options("white")      # color de las opciones no seleccionadas
menu.SetStyle.Focus("green", 2)     # color de la opción resaltada

Colores disponibles: black, red, green, yellow, blue, magenta, cyan, white.

Estilos de borde (style)

El parámetro style acepta un número que define cómo se dibuja el marco del menú:

style Vista previa style Vista previa
1 #===# 11 ░░░░░
2 ┌───┐ 12 █████
3 ╔═══╗ 13 *****
4 ┏━━━┓ 14 +++++
5 ╒═══╕ 15 =====
6 ╓───╖ 16 ~~~~~
7 ╭───╮ 17 -----
8 ▛▀▀▀▜ 18 ◆◆◆◆◆
9 ▓▓▓▓▓ 19 ●●●●● (default)
10 ▒▒▒▒▒ 20 ★★★★★
menu = GRmenu([opcion_uno, opcion_dos], title="Mi menu", style=7)  # bordes redondeados

Ancho del menú

draw() acepta size_max, el ancho mínimo en caracteres del cuadro (se expande automáticamente si el título o las opciones son más largos):

menu.draw(size_max=30)

📖 Referencia de la API

GRmenu(functions, title="", style=19)

Parámetro Tipo Descripción
functions list[Callable] Funciones a mostrar como opciones, en orden.
title str Título mostrado en la cabecera del menú.
style int Número de estilo de borde (ver tabla arriba).

menu.draw(size_max=20)

Dibuja el menú y bloquea el hilo hasta que el usuario elige una opción (Enter) o sale (q).

menu.SetStyle

Método Descripción
SetStyle.Border(color, level=1) Color del marco del menú.
SetStyle.Options(color, level=1) Color de las opciones sin seleccionar.
SetStyle.Focus(color, level=2) Color de la opción resaltada.

🧩 Ejemplo completo

from GRmenu import GRmenu

def saludar():
    print("¡Hola!")

def salir_app():
    print("Hasta luego 👋")

def acerca_de():
    print("GRmenu v0.1.0 — menú TTY para terminal")

menu = GRmenu(
    [saludar, acerca_de, salir_app],
    title="GRmenu Demo",
    style=7,
)
menu.SetStyle.Border("magenta")
menu.SetStyle.Options("white")
menu.SetStyle.Focus("cyan", 2)
menu.draw(size_max=28)

🤝 Contribuir

Las contribuciones son bienvenidas. Podés abrir un issue o enviar un pull request.


📄 Licencia

Distribuido bajo licencia MIT.


Hecho por grcode

Download files

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

Source Distribution

grmenu-0.1.3.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

grmenu-0.1.3-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file grmenu-0.1.3.tar.gz.

File metadata

  • Download URL: grmenu-0.1.3.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for grmenu-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6cf2a9d84fc40e0a2a6c404f5c4b109eb0cecafba6a21abda421bbdbd54afcdc
MD5 4ec7df7e986403198def33f4d432e4c6
BLAKE2b-256 6da0814314b20587b1b402bc2e6ff33027e4eaac6843e041b34fbc6d2c23bcbf

See more details on using hashes here.

Provenance

The following attestation bundles were made for grmenu-0.1.3.tar.gz:

Publisher: auto-release.yml on JoseEduardoGR/GRmenu

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file grmenu-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: grmenu-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for grmenu-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8e63c85208cfd22674c5a8c2a543a3e1ccd20fabb4c6ad264669d298d94e1cab
MD5 b8cef20e7c0960b6088a1320d37e9bc5
BLAKE2b-256 2625b230cd4e1ad839d6ce277ae8ed0c766eafa96af382956c47df87c8b61245

See more details on using hashes here.

Provenance

The following attestation bundles were made for grmenu-0.1.3-py3-none-any.whl:

Publisher: auto-release.yml on JoseEduardoGR/GRmenu

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

This release

0.1.3 This release

2 files

0.1.2

2 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