Class CmdInfo
- class ooodev.gui.commands.CmdInfo[source]
Singleton Class. Gets Information about commands.
Processing all the commands in all the modules takes some time. The first time the command data is retrieved, it is cached. The next time the command data is retrieved, it is retrieved from the cache. The cache valid for 5 days (may be cleared sooner, depending on system). The
clear_cache()method can be used to clear the cache sooner.Example
>>> from ooodev.utils.kind.module_names_kind import ModuleNamesKind >>> from ooodev.gui.commands.cmd_info import CmdInfo >>> inst = CmdInfo() >>> cmd_data = inst.get_cmd_data(ModuleNamesKind.SPREADSHEET_DOCUMENT, ".uno:Copy") >>> if cmd_data: ... print(cmd_data) CmdData( command='.uno:Copy', label='Cop~y', name='Copy', popup=False, properties=1, popup_label='', tooltip_label='', target_url='', is_experimental=False, module_hotkey='', global_hotkey='Ctrl+C' )
See also
- find_command(command)[source]
Find a command by name. All Modules are searched and the dictionary key is the module name.
- Parameters:
command (str) – The command name such as
.uno:Copy.- Returns:
A dictionary of module names and command rows.
- Return type:
dict
Note
Triggers the
CmdInfo_command_foundevent. If the event is canceled the command is not added to the result. Seesubscribe_on_command_found().The
event_datahas the following event data: -module_name: The module name. -cmd_data: Instance ofCmdDataThe command data.
- get_cmd_data(mode_name, cmd)[source]
Gets the command data.
- Parameters:
mode_name (str | ModuleNamesKind) – Module name such as
com.sun.star.presentation.PresentationDocument.cmd (str) – Command name such as
.uno:Copy.
- Returns:
The command data or
Noneif not found.- Return type:
CmdData | None
Hint
ModuleNamesKindis an enum and can be imported fromooodev.utils.kind.module_names_kind.
- get_dict(mod_name)[source]
Gets a dictionary of command data. The key is the command name such as
.uno:Copy.- Parameters:
mod_name (str | ModuleNamesKind) – Module name such as
com.sun.star.presentation.PresentationDocument.- Returns:
A dictionary of command data.
- Return type:
Dict[str, CmdData]
Hint
ModuleNamesKindis an enum and can be imported fromooodev.utils.kind.module_names_kind.
- get_module_names()[source]
Get a list of module names such as
com.sun.star.presentation.PresentationDocument.- Return type:
Tuple[str,...]
- has_command(mode_name, cmd)[source]
Gets if a module contains a command.
- Parameters:
mode_name (str | ModuleNamesKind) – Module name such as
com.sun.star.presentation.PresentationDocument.cmd (str) – Command name such as
.uno:Copy.
- Returns:
Trueif the command is found; Otherwise,False.- Return type:
bool
Hint
ModuleNamesKindis an enum and can be imported fromooodev.utils.kind.module_names_kind.
- subscribe_on_command_found(cb)[source]
Subscribe on command found event.
The callback
event_datais a dictionary with keys:module_name: The module name.cmd_data: Instance ofCmdDataThe command data.
- Return type:
None- Parameters:
cb (Callable[[Any, CancelEventArgs], None]) –
- unsubscribe_on_command_found(cb)[source]
Unsubscribe on command found event.
- Return type:
None- Parameters:
cb (Callable[[Any, CancelEventArgs], None]) –