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.2.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.2-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: grmenu-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 db12c3bb0e691d1e4650505bf1046c4ba07ad15c5daf850aeb6fb2adbe6fddb3
MD5 3d7c7a7c8565d9f42d36293d48518c0c
BLAKE2b-256 21cf2027ee04440b670b9e67057787c5ff7cbd8a94c5c74e2c0d168242767410

See more details on using hashes here.

Provenance

The following attestation bundles were made for grmenu-0.1.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: grmenu-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4fbfaab2ac4c395ab45070461a52ce4f79fa9f30b493c01f05860130d1e438e1
MD5 a9c690fb2a4832e293b9490f5eeec43c
BLAKE2b-256 c8ef40b38d16638f87b0c16dc8adf5b1b54c05a3d186d4a868f5e9fd25caa5f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for grmenu-0.1.2-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

0.1.3

2 files

This release

0.1.2 This release

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