Creating a menu using MenuApp

from ooodev.calc import CalcDoc
from ooodev.utils.kind.menu_lookup_kind import MenuLookupKind

doc = CalcDoc.create_doc(loader=loader, visible=True)
menu = doc.menu[MenuLookupKind.TOOLS] # or .menu[".uno:ToolsMenu"]
itm = menu.items[".uno:AutoComplete"] # or .items[6]

menu_name = ".custom:my.custom_menu"
new_menu = {
    "Label": "My Menu",
    "CommandURL": menu_name,
    "Submenu": [
        {
            "Label": "Execute macro...",
            "CommandURL": "RunMacro",
            "ShortCut": "Shift+Ctrl+Alt+E",
        },
        {
            "Label": "My macro",
            "CommandURL": {"library": "test", "name": "hello"},
            "ShortCut": {"key": "Shift+Ctrl+Alt+F", "save": True},
        },
    ],
}
if not menu_name in menu:
    # only add the menu if it does not already exist
    menu.insert(new_menu, after=itm.command, save=True)

In this case doc.menu is MenuApp for Calc menus.

Config