Class MenuBase

class ooodev.gui.menu.common.menu_base.MenuBase(*, node, config, menus, app='', lo_inst=None)[source]

Bases: LoInstPropsPartial

Class Base for menus

Parameters:
__init__(*, node, config, menus, app='', lo_inst=None)[source]

Constructor

Parameters:
  • node (str) – Menu Node such as private:resource/menubar/menubar.

  • config (UIConfigurationManagerComp) – Configuration Manager.

  • menus (IndexAccessComp[Tuple[PropertyValue, ...]]) – Menus.

  • app (str | Service, optional) – App Name such as Service.CALC. Defaults to “”. If no app is provided, the global shortcuts will be used.

  • lo_inst (LoInst, optional) – LibreOffice Instance. Defaults to None.

Hint

  • Service is an enum and can be imported from ooodev.loader.inst.service

insert(parent, menu, after='')[source]

Insert new menu.

Parameters:
  • parent (Any) – Menu parent

  • menu (Dict[str, Any]) – New menu data

  • after (int | str, optional) – After menu insert. Defaults to “”.

Return type:

None

remove(parent, name, save=False)[source]

Remove name in parent.

Parameters:
  • parent (Any) – Menu parent. UNO object.

  • name (str, Dict[str, str]) – Menu CommandURL or data.

  • save (bool, optional) – Save changes. Defaults to False.

Return type:

None

validate_keys(dictionary, valid_keys)[source]

Validate keys in dictionary.

Parameters:
  • dictionary (dict) – Dictionary to validate.

  • valid_keys (Iterable[str]) – Valid keys.

Returns:

True if all keys are valid.

Return type:

bool

VALID_KEYS = {'CommandURL', 'ItemDescriptorContainer', 'Label', 'ShortCut', 'Style', 'Type'}
property app: str
Return type:

str

property config: UIConfigurationManagerComp
Return type:

UIConfigurationManagerComp

property menus: IndexAccessComp[Tuple[PropertyValue, ...]]
Return type:

IndexAccessComp[Tuple[PropertyValue, ...]]