UI: update tool docstring

Also assert on invalid tool definitions.
This commit is contained in:
Campbell Barton 2018-04-26 07:39:15 +02:00
parent 37ca6ef7d8
commit 3e2edb160f

@ -41,13 +41,15 @@ class ToolSelectPanelHelper:
- tools_from_context(context): - tools_from_context(context):
Returns tools available in this context. Returns tools available in this context.
Each tool is a triplet: Each tool is a dict:
``(tool_name, manipulator_group_idname, keymap_actions)`` ``(text=tool_name, icon=icon_name, widget=manipulator_group_idname, keymap=keymap_actions)``
For a separator in the toolbar, use ``None``. For a separator in the toolbar, use ``None``.
Where: Where:
``tool_name`` ``tool_name``
is the name to display in the interface. is the name to display in the interface.
``icon_name``
is the name of the icon to use (found in ``release/datafiles/icons``).
``manipulator_group_idname`` ``manipulator_group_idname``
is an optional manipulator group to activate when the tool is set. is an optional manipulator group to activate when the tool is set.
``keymap_actions`` ``keymap_actions``
@ -96,6 +98,9 @@ class ToolSelectPanelHelper:
@classmethod @classmethod
def _tool_vars_from_def(cls, item): def _tool_vars_from_def(cls, item):
# For now be strict about whats in this dict
# prevent accidental adding unknown keys.
assert(len(item) == 4)
text = item["text"] text = item["text"]
icon_name = item["icon"] icon_name = item["icon"]
mp_idname = item["widget"] mp_idname = item["widget"]