SelectionMenu — Quickly get a selection¶
Bases: consolemenu.ConsoleMenu
-
class
consolemenu.
SelectionMenu
(strings, title=None, subtitle=None, screen=None, formatter=None, prologue_text=None, epilogue_text=None, show_exit_option=True, exit_option_text='Exit', clear_screen=True)[source]¶ A menu that simplifies item creation, just give it a list of strings and it builds the menu for you
Parameters: - strings (
list
ofstr
) – The list of strings this menu should be built from. - title (str) – The title of the menu.
- subtitle (str) – The subtitle of the menu.
- screen (
consolemenu.screen.Screen
) – The screen object associated with this menu. - formatter (
MenuFormatBuilder
) – The MenuFormatBuilder instance used to format this menu. - prologue_text (str) – Text to include in the “prologue” section of the menu.
- epilogue_text (str) – Text to include in the “epilogue” section of the menu.
- show_exit_option (bool) – Specifies whether this menu should show an exit item by default. Defaults to True. Can be overridden when the menu is started.
- exit_option_text (str) – Text for the Exit menu item. Defaults to ‘Exit’.
- clear_screen (bool) – Set to False to disable clearing of screen between menus
-
classmethod
get_selection
(strings, title='Select an option', subtitle=None, show_exit_option=True, _menu=None)[source]¶ Single-method way of getting a selection out of a list of strings.
Parameters: - strings (
list
ofstr
) – The list of strings this menu should be built from. - title (str) – The title of the menu.
- subtitle (str) – The subtitle of the menu.
- show_exit_option (bool) – Specifies whether this menu should show an exit item by default. Defaults to True.
- _menu – Should probably only be used for testing, pass in a list and the created menu used internally by the method will be appended to it
Returns: The index of the selected option.
Return type: int
- strings (
- strings (