I need to disable my custom drawing tool when I enable the zoom tool because otherwise my draw toll continues drawing as I am zooming.
I can disable the zoom and pan tools when I select my custom tool like this:
class MyDrawingTool(ToolToggleBase):
def __init__(self, *args, **kwargs):
self.fig = kwargs.pop('fig')
ToolToggleBase.__init__(self, *args, **kwargs)
def enable(self, *args):
print("pitch enabled")
state = self.fig.canvas.manager.toolbar.toolmanager.active_toggle["default"]
if state=='zoom' or state=='pan':
self.fig.canvas.manager.toolbar.toolmanager.trigger_tool(state)
and in my code i add the tool this way:
fig.canvas.manager.toolmanager.add_tool('Pitch', MyDrawingTool, fig=self.fig )
fig.canvas.manager.toolbar.add_tool('Pitch', 'navigation')
But I cannot do the reverse: I cannot disable MyDrawingTool when I activate the zoom tool because I do not have access to the zoom tool enable function to make it call MyDrawingTool's disableFunction.
I thought that using a ToolToggleBase object and adding it to the 'navigation' toolbar (which seems to be the default toolbar where zoom tool lives right?) would make it so that only one of the tools in the toolbar would be active at a time and that I would not have to implement extra enable/disable functionality for other tools.
what am i missing?
Is there a way to catch a "zoom tool has been enabled" event somehow?