curses-menu
master

Contents:

  • Installation
  • Usage
  • API Reference
    • CursesMenu — Standard menu class
    • ItemGroup — A group of MenuItems
    • Items
      • CommandItem
      • ExitItem
      • ExternalItem
      • FunctionItem
      • MenuItem
        • MenuItem
      • SubmenuItem
    • Functions
curses-menu
  • API Reference
  • Items
  • MenuItem
  • Edit on GitHub

MenuItem

class cursesmenu.items.MenuItem(text, menu=None, *, should_exit=False, override_index=None)[source]

The base class for menu items.

Is displayed in a basic manner and does nothing when selected.

Parameters
  • text (str) – The text representing this menu item

  • should_exit (bool) – Whether the menu should exit when this item is selected

  • menu (Optional[Any]) – The menu that owns this item

action()[source]

Do the main action for the item.

If you’re just writing a simple subclass, you shouldn’t need set_up or clean_up. The menu just calls them in order. They are provided so you can make subclass hierarchies where the superclass handles some setup and cleanup for its subclasses.

Return type

None

clean_up()[source]

Perform cleanup for the item.

Return type

None

get_return()[source]

Get the return value for this item.

For a basic MenuItem, just forwards the return value from the menu.

Return type

Any

Returns

The return value for the item.

set_up()[source]

Perform setup for the item.

Return type

None

show(index_text)[source]

Provide the representation that should be used for this item in a menu.

The base class is simply “[index] - [text]”

Parameters

index_text (str) – The string used for the index, provided by the menu.

Return type

str

Returns

The text representing the item.

Previous Next

© Copyright 2021, Paul Barrett. Revision 2e3bdb08.

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