Add a tool to this container. Parameters ---------- tool : tool_like The tool to add, see `.ToolManager.get_tool`. group : str The name of the group to add this tool to. position : int, default: -1 The position wit
(self, tool, group, position=-1)
| 3468 | self.toggle_toolitem(event.tool.name, event.tool.toggled) |
| 3469 | |
| 3470 | def add_tool(self, tool, group, position=-1): |
| 3471 | """ |
| 3472 | Add a tool to this container. |
| 3473 | |
| 3474 | Parameters |
| 3475 | ---------- |
| 3476 | tool : tool_like |
| 3477 | The tool to add, see `.ToolManager.get_tool`. |
| 3478 | group : str |
| 3479 | The name of the group to add this tool to. |
| 3480 | position : int, default: -1 |
| 3481 | The position within the group to place this tool. |
| 3482 | """ |
| 3483 | tool = self.toolmanager.get_tool(tool) |
| 3484 | image = self._get_image_filename(tool) |
| 3485 | toggle = getattr(tool, 'toggled', None) is not None |
| 3486 | self.add_toolitem(tool.name, group, position, |
| 3487 | image, tool.description, toggle) |
| 3488 | if toggle: |
| 3489 | self.toolmanager.toolmanager_connect('tool_trigger_%s' % tool.name, |
| 3490 | self._tool_toggled_cbk) |
| 3491 | # If initially toggled |
| 3492 | if tool.toggled: |
| 3493 | self.toggle_toolitem(tool.name, True) |
| 3494 | |
| 3495 | def _get_image_filename(self, tool): |
| 3496 | """Resolve a tool icon's filename.""" |
nothing calls this directly
no test coverage detected