Skip to content
MilesWK edited this page Apr 10, 2024 · 1 revision

Menu()

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:

  1. This is the default type of menu. It adds a ">" in front of the selected item
  2. This highlights the selected item in white.
  3. This changes the color of the selected item to red.
Clone this wiki locally