Bash Menu Builder
Project description
Bash Menu Builder
This package help you build menu for yours console scripts
Installation | Usage | Draw menu | How it works
Installation
For install package to your project use this command:
pip3 install bash-menu-builder
Usage
Script give opportunity use two type views of menu:
The Input type Menu
from bash_menu_builder import InputMenu, MenuItemDto
def banner_text() -> str:
return 'I\'m Banner Text'
def function_one() -> None:
print('Script One')
def function_two() -> None:
print('Script Two')
def function_three() -> None:
print('Script Three')
if __name__ == "__main__":
InputMenu(
menu=[
MenuItemDto(title='Test', option='one', handler=function_one),
MenuItemDto(title='Test2', option='two', handler=function_two),
MenuItemDto(title='Test3', option='three', handler=function_three),
],
banner=banner_text()
)
View Menu
The Select type Menu
from bash_menu_builder import SelectMenu, MenuItemDto
def banner_text() -> str:
return 'I\'m Banner Text'
def function_one() -> None:
print('Script One')
def function_two() -> None:
print('Script Two')
def function_three() -> None:
print('Script Three')
if __name__ == "__main__":
SelectMenu(
menu=[
MenuItemDto(title='Menu Item One', option='one', handler=function_one),
MenuItemDto(title='Menu Item Two', option='two', handler=function_two),
MenuItemDto(title='Menu Item Three', option='three', handler=function_three),
],
banner=banner_text()
)
View Menu
Draw menu
The menu draw via class View
which get params of array with DTOs and text of banner (optional)
The MenuItemDto have 3 params def __init__(self, title: str, option_name: str, handler: object):
title: str
- the title of menu itemoption_name: str
- the option name for call menu via consolehandler: object
- the handler of menu item. What exactly script do after select this menu item.
How it works
After select menu number and press Enter will run script in function. When script finish process menu will draw again.
Also you can call script without drawing menu. Just set option when call python script file, ex. python3 main.py --three
In this case will run script for menu 'Menu Item Three'. When script finish process menu will not draw again and program will close.
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 bash_menu_builder-1.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 518ec6a619e87ed04ff3d33961f966af2eff1bf016c82e0e0383bc006c5ee17a |
|
MD5 | e1aedcc23ee65ed2f97fccd216259838 |
|
BLAKE2b-256 | bb555da1b172a151194265b9168b895bfb62b91025ed6c2414768dd4582b33ee |