Command line menu selector.
Project description
menuchoice
Command line menu selector.
Usage
Creating a selection menu:
import menuchoice
myMenu = menuchoice.MenuSelector(items=[
"Hip-hop",
"Rock",
"Pop",
"Country",
"EDM",
], title="Most Streamed Music USA", description="Select a genre of music.")
[!TIP] items can be given brief descriptions if they are type dictionary:
{"option": "brief description"}
Selecting an option:
myMenu.prompt_select() # basic user-input method
myMenu.arrow_select()
Output:
[(4, "EDM")]
Additionally, multiple options can be selected
# no less than 2, no more than 3
myMenu.arrow_select(max_items=(2, 3))
# Adds an option to select all items
myMenu.arrow_select(allow_all=True)
Output:
[(4, "EDM"), (1, "Rock")]
Highlight menu
Highlight menus introduce the ability to have multiple pages (this is optional):
myMenu.highlight_select(pages=[[0, 1, 2], [3, 4]])
The above code will create two pages, the first page contains the first three options, the second contains the last two options.
To switch between these pages, use the left/right arrow keys.
The highlight menu can also disable options:
myMenu.highlight_select(disabled_items=[3])
This code above will prevent to user from selecting index 3 of the menus items (the fourth option).
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.