Python console menu
Project description
pymenu
pymenu is a python library for creating interactive, console-based menus. It allows for the creation of menus that can be controlled with keyboard arrows, and can also automatically generate menus from files in a folder.
Installation
To install pymenu, simply run the following command:
pip install pymenu-console
Usage
pymenu makes it easy to create menus for your console applications. You can create a menu from files in a folder, or create a selector menu, in which the user chooses an option and the option is returned in the function.
Examples
Simple menu
Here is an example of how to create a menu with pymenu:
from pymenu import Menu
menu = Menu('Menu title')
menu.add_option("Option 1", lambda: print("Option 1"))
menu.add_option("Option 2", lambda: print("Option 2"))
menu.add_option("Option 3", lambda: print("Option 3"))
menu.show()
Menu with submenus
Here is an example of how to create a menu with submenus using pymenu:
from pymenu import Menu
menu = Menu('Menu title')
menu.add_option("Option 1", lambda: print("Option 1"))
menu.add_option("Option 2", lambda: print("Option 2"))
menu.add_option("Option 3", lambda: print("Option 3"))
submenu = Menu('Submenu title')
submenu.add_option("Suboption 1", lambda: print("Suboption 1"))
submenu.add_option("Suboption 2", lambda: print("Suboption 2"))
submenu.add_option("Suboption 3", lambda: print("Suboption 3"))
menu.add_option("Submenu", submenu)
menu.show()
Automatic menu of a folder
Here's an example of how to automatically create a menu from a folder with pymenu:
from pymenu import auto_menu
menu = auto_menu.create_menu_from_directory('directory')
menu.add_option('Exit', exit)
menu.show()
Selector menu
Here is an example of how to create a selector menu with pymenu:
from pymenu import select_menu
options = ['Option 1', 'Option 2', 'Option 3']
selected_option = select_menu.create_select_menu(options, 'Select an option')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pymenu_console-0.1.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4faf65b37685530e765c2d33411d9328ff35c2d50028c9815a1537ac6073bc3e |
|
MD5 | 4370dd76d14b0e738f19a7b5ed2acff9 |
|
BLAKE2b-256 | fae9ccdaa2ac5d849010157b697eb3fd71a1a2c56e1665dba05b20ac37ef499a |