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

Gem Version PyPI version Ruby Python versions License: MIT 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 bloques
  • 🌈 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 (io/console en Ruby, termios/tty en Python)
  • 💎 Ruby & Python — disponible como gema de Ruby (grmenu) y como paquete pip de Python (grmenu)
  • 🐧 Linux / macOS — funciona en cualquier terminal POSIX

⚠️ Requiere una terminal real (TTY) en Linux o macOS. En Ruby utiliza io/console en modo crudo (raw) y en Python termios/tty para capturar pulsaciones de teclas en tiempo real.


📦 Instalación

Ruby (RubyGems)

gem install grmenu

O en tu Gemfile:

gem 'grmenu'

Python (PyPI)

pip install grmenu

🚀 Uso rápido

💎 Ruby

require 'GRmenu'

def opcion_uno
  puts "elegiste uno"
end

def opcion_dos
  puts "elegiste dos"
end

menu = GRmenu.new(
  [method(:opcion_uno), method(:opcion_dos)],
  title: "Mi menu",
  style: 19
)

menu.set_style.border("yellow")
menu.set_style.options("green")
menu.draw

Cada elemento de la lista puede ser un Method (method(:mi_metodo)), un Proc / lambda (-> { ... }), un arreglo ["Nombre", callable] o un Symbol (:mi_metodo). Al presionar Enter, esa acción se ejecuta.

🐍 Python

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 / set_style)

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

En Ruby:

menu.set_style.border("cyan")        # color del borde
menu.set_style.options("white")      # color de las opciones no seleccionadas
menu.set_style.focus("green", 2)     # color de la opción resaltada (brillante)

En Python:

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 (brillante)

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

Estilos de borde (style)

El parámetro style acepta un número (1 al 20) 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 ★★★★★
# Ruby
menu = GRmenu.new([method(:opcion_uno), method(:opcion_dos)], title: "Mi menu", style: 7)  # bordes redondeados
# Python
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):

# Ruby
menu.draw(size_max: 30)
# Python
menu.draw(size_max=30)

📖 Referencia de la API

💎 Ruby

GRmenu.new(functions, title: "", style: 19)

Parámetro Tipo Descripción
functions Array<Method, Proc, Symbol, Array> Métodos, procs o lambdas a mostrar como opciones.
title String (opcional) Título mostrado en la cabecera del menú.
style Integer (opcional) Número de estilo de borde (ver tabla arriba).

menu.draw(size_max: 20)

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

menu.set_style

Método Descripción
set_style.border(color, level=1) Color del marco del menú.
set_style.options(color, level=1) Color de las opciones sin seleccionar.
set_style.focus(color, level=2) Color de la opción resaltada.

(Nota: también se admiten los alias menu.SetStyle.Border(...), menu.SetStyle.Options(...), menu.SetStyle.Focus(...)).


🐍 Python

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.

🧩 Ejemplos completos

💎 Ejemplo completo en Ruby

require 'GRmenu'

def saludar
  puts "¡Hola desde Ruby!"
end

def salir_app
  puts "Hasta luego 👋"
end

def acerca_de
  puts "GRmenu v0.1.4 — menú TTY para terminal"
end

menu = GRmenu.new(
  [
    method(:saludar),
    method(:acerca_de),
    ["Personalizado", -> { puts "Opción con bloque lambda" }],
    method(:salir_app)
  ],
  title: "GRmenu Demo (Ruby)",
  style: 7
)

menu.set_style.border("magenta")
menu.set_style.options("white")
menu.set_style.focus("cyan", 2)
menu.draw(size_max: 28)

🐍 Ejemplo completo en Python

from GRmenu import GRmenu

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

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

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

def personalizado():
    print("Opción personalizada en Python")

menu = GRmenu(
    [
        saludar,
        acerca_de,
        personalizado,
        salir_app
    ],
    title="GRmenu Demo (Python)",
    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

Metadata

Release files for grmenu 2.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for grmenu 2.1.2
File Size Uploaded Provenance
grmenu-2.1.2.tar.gz 19.7 kB With provenance Details

Built distribution (wheel)

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

Total release size: 40.6 kB

Release files / grmenu-2.1.2.tar.gz

Download URL grmenu-2.1.2.tar.gz
Size 19.7 kB
Tags Source
SHA-256 checksum
How to use checksums
08bbba015b7f8e20c5e9fbc2b7851713a582531b548b35141c8b5fa2816a4f94
BLAKE2b-256 checksum
How to use checksums
6051873cfa8a7bda92648209c27a6187e935cd73680893be2ecbdf40c93c78da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.

Transparency log

Release files / grmenu-2.1.2-py3-none-any.whl

Download URL grmenu-2.1.2-py3-none-any.whl
Size 20.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0310d9b7c6507004ca81cdd93e56d55b38202390693b5e046b4b2ac61ed68f6e
BLAKE2b-256 checksum
How to use checksums
88eba52c60811f515eef18e52515c8684704716470f53b710155f8b69c7665e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.

Transparency log

Security for grmenu 2.1.2

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for grmenu-2.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 30, 2026.

Transparency log

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.

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