earwax.menus.menu_item module¶
Provides the MenuItem class.
-
class
earwax.menus.menu_item.MenuItem(func: Callable[[], Optional[Generator[None, None, None]]], title: Union[str, TitleFunction, None] = None, select_sound_path: Optional[pathlib.Path] = None, loop_select_sound: bool = False, activate_sound_path: Optional[pathlib.Path] = None)¶ Bases:
earwax.mixins.RegisterEventMixinAn item in a
Menu.This class is rarely used directly, instead
earwax.menu.Menu.add_item()orearwax.menu.Menu.item()can be used to return an instance.Variables: - func – The function which will be called when this item is activated.
- title –
The title of this menu item.
If this value is a callable, it should return a string which will be used as the title.
- select_sound_path –
The path to a sound which should play when this menu item is selected.
If this value is
None(the default), then no sound will be heard unless the containing menu has itsitem_select_sound_pathattribute set to something that is notNone, orearwax.EarwaxConfig.menus.default_item_select_soundis notNone. - activate_sound_path –
The path to a sound which should play when this menu item is activated.
If this value is
None(the default), then no sound will be heard unless the containing menu has itsitem_activate_sound_pathattribute set to something that is notNone, orearwax.EarwaxConfig.menus.default_item_select_soundis notNone.
-
get_title() → Optional[str]¶ Return the proper title of this object.
If
self.titleis a callable, its return value will be returned.
-
on_selected() → None¶ Handle this menu item being selected.