-
Notifications
You must be signed in to change notification settings - Fork 0
menu
MilesWK edited this page Apr 10, 2024
·
1 revision
Usage: menu(array, menutype)
array: the array (or list) of items that will be the options in the menu.
Menu()
allows you to create responsive menus that work when running the python project in the terminal. The user can use the up or down arrow keys to choose an item, and then click enter to select the selected item. The function will then return the selection. Here is an example use of this feature:
import texttoolspy as ttp
MenuItems = ["1","2","3"]
Menu = ttp.menu(MenuItems, 1) # menuitems is our list, and 1 is the type of menu
print(f"You have selected {Menu} as your choice")
This will show this before the user presses enter/return:
> 1
2
3
If the user presses enter, then you will get this output:
You have selected 1 as your choice
Menu types: There are three types of menus to choose from. Here is the list:
- This is the default type of menu. It adds a ">" in front of the selected item
- This highlights the selected item in white.
- This changes the color of the selected item to red.