mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-14 18:27:51 -06:00
34 lines
No EOL
1.3 KiB
Python
34 lines
No EOL
1.3 KiB
Python
# Copyright (c) 2018 Ultimaker B.V.
|
|
# Cura is released under the terms of the LGPLv3 or higher.
|
|
|
|
from cura.CuraApplication import CuraApplication
|
|
|
|
## The sidebar context menu API provides a version-proof bridge between Cura's
|
|
# Sidebar Context Menu and plug-ins that hook into it.
|
|
#
|
|
# Usage:
|
|
# ``from cura.API import CuraAPI
|
|
# api = CuraAPI()
|
|
# api.sidebar.getContextMenuItems()
|
|
# menu_actions = []
|
|
# menu_actions.append("sidebarMenuItemOnClickHandler")
|
|
# data = {
|
|
# "name": "My Plugin Action",
|
|
# "iconName": "my-plugin-icon",
|
|
# "actions": menu_actions,
|
|
# "menu_item": MyPluginAction(self)
|
|
# }
|
|
# api.sidebar.addContextMenuItem(data)``
|
|
class Sidebar:
|
|
|
|
_application = CuraApplication.getInstance() # type: CuraApplication
|
|
|
|
## Add items to the sidebar context menu.
|
|
# \param menu_item dict containing the menu item to add.
|
|
def addContextMenuItem(self, menu_item: dict) -> None:
|
|
self._application.addSidebarCustomMenuItem(menu_item)
|
|
|
|
## Get all custom items currently added to the sidebar context menu.
|
|
# \return List containing all custom context menu items.
|
|
def getContextMenuItems(self) -> list:
|
|
return self._application.getSidebarCustomMenuItems() |