Skip to main content

A simple console menu system

Project description

Build StatusDocumentation Status

console-menu

A simple Python menu-based UI system for terminal applications. Perfect for those times when you need a menu-driven program, but don’t want the overhead or learning curve of a full-fledged GUI framework.

Derived from the curses-menu project, but with curses dependency removed.

http://console-menu.readthedocs.org/en/latest/

./images/console-menu_screenshot1.png ./images/console-menu_screenshot2.png

Installation

Tested on Python 2.7, 3.4, 3.5, and 3.6, as well as pypy and pypy 3.

Installation can be performed by running pip

pip install console-menu

Usage

It’s designed to be pretty simple to use. Here’s an example

# Import the necessary packages
from consolemenu import *
from consolemenu.items import *

# Create the menu
menu = ConsoleMenu("Title", "Subtitle")

# Create some items

# MenuItem is the base class for all items, it doesn't do anything when selected
menu_item = MenuItem("Menu Item")

# A FunctionItem runs a Python function when selected
function_item = FunctionItem("Call a Python function", input, ["Enter an input"])

# A CommandItem runs a console command
command_item = CommandItem("Run a console command",  "touch hello.txt")

# A SelectionMenu constructs a menu from a list of strings
selection_menu = SelectionMenu(["item1", "item2", "item3"])

# A SubmenuItem lets you add a menu (the selection_menu above, for example)
# as a submenu of another menu
submenu_item = SubmenuItem("Submenu item", selection_menu, menu)

# Once we're done creating them, we just add the items to the menu
menu.append_item(menu_item)
menu.append_item(function_item)
menu.append_item(command_item)
menu.append_item(submenu_item)

# Finally, we call show to show the menu and allow the user to interact
menu.show()

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

console-menu-0.2.0.tar.gz (33.1 kB view details)

Uploaded Source

Built Distribution

console_menu-0.2.0-py2.py3-none-any.whl (22.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file console-menu-0.2.0.tar.gz.

File metadata

File hashes

Hashes for console-menu-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a3e0b765c2cb40cb1f20c64262806fe30721fa379805f99666d25e3a26ab9030
MD5 7f112c8f9c8ad243eda10d1a71a80415
BLAKE2b-256 b841c8fa60a75de01bbd654ebd6b53e3cd728316ab8c44e3c9286fbdac0e6434

See more details on using hashes here.

File details

Details for the file console_menu-0.2.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for console_menu-0.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 650815ae213abb6a2e7ee3351ff59d5017ec34842c5abeeb8a7b411fdc394ce3
MD5 51dbd701ab0f30a5bee6667cfb0b6084
BLAKE2b-256 18fd5525923c92814292c2cc206167038cd3d54ea8eeae8ce8e9d7319f6ff1a2

See more details on using hashes here.

Supported by

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