console-menu
stable
  • Installation
  • Usage
  • API Reference
    • ConsoleMenu — Standard menu class
    • SelectionMenu — Quickly get a selection
    • MultiSelectMenu — Make multiple selections at one prompt
    • Items
      • CommandItem
      • ExitItem
      • ExternalItem
      • FunctionItem
      • MenuItem
      • SelectionItem
      • SubmenuItem
    • Functions
    • Screen
    • Menu Components
    • Formatting
    • Prompts
console-menu
  • Docs »
  • API Reference »
  • Items »
  • MenuItem
  • Edit on GitHub

MenuItem¶

class consolemenu.items.MenuItem(text, menu=None, should_exit=False, menu_char=None)[source]¶

A generic menu item

Variables:
  • text (str) – The text shown for this menu item
  • menu (ConsoleMenu) – The menu to which this item belongs
  • should_exit (bool) – Whether the menu should exit once this item’s action is done
  • menu_char (str) – The character used to select this menu item. Optional - defaults to None.
action()[source]¶

Override to carry out the main action for this item.

clean_up()[source]¶

Override to add any cleanup actions necessary for the item

get_return()[source]¶

Override to change what the item returns. Otherwise just returns the same value the last selected item did.

set_up()[source]¶

Override to add any setup actions necessary for the item

show(index)[source]¶

How this item should be displayed in the menu. Can be overridden, but should keep the same signature.

Default is:

1 - Item 1

2 - Another Item

Parameters:index (int) – The index of the item in the items list of the menu
Returns:The representation of the item to be shown in a menu
Return type:str
Next Previous

© Copyright 2018, Aegir Hall, 2015, Paul Barrett Revision f6b00890.

Built with Sphinx using a theme provided by Read the Docs.