MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _handle_toggle

Method _handle_toggle

lib/matplotlib/backend_managers.py:272–313  ·  view source on GitHub ↗

Toggle tools, need to untoggle prior to using other Toggle tool. Called from trigger_tool. Parameters ---------- tool : `.ToolBase` canvasevent : Event Original Canvas event or None. data : object Extra data to pass to

(self, tool, canvasevent, data)

Source from the content-addressed store, hash-verified

270 return tool_obj
271
272 def _handle_toggle(self, tool, canvasevent, data):
273 """
274 Toggle tools, need to untoggle prior to using other Toggle tool.
275 Called from trigger_tool.
276
277 Parameters
278 ----------
279 tool : `.ToolBase`
280 canvasevent : Event
281 Original Canvas event or None.
282 data : object
283 Extra data to pass to the tool when triggering.
284 """
285
286 radio_group = tool.radio_group
287 # radio_group None is not mutually exclusive
288 # just keep track of toggled tools in this group
289 if radio_group is None:
290 if tool.name in self._toggled[None]:
291 self._toggled[None].remove(tool.name)
292 else:
293 self._toggled[None].add(tool.name)
294 return
295
296 # If the tool already has a toggled state, untoggle it
297 if self._toggled[radio_group] == tool.name:
298 toggled = None
299 # If no tool was toggled in the radio_group
300 # toggle it
301 elif self._toggled[radio_group] is None:
302 toggled = tool.name
303 # Other tool in the radio_group is toggled
304 else:
305 # Untoggle previously toggled tool
306 self.trigger_tool(self._toggled[radio_group],
307 self,
308 canvasevent,
309 data)
310 toggled = tool.name
311
312 # Keep track of the toggled tool in the radio_group
313 self._toggled[radio_group] = toggled
314
315 def trigger_tool(self, name, sender=None, canvasevent=None, data=None):
316 """

Callers 2

add_toolMethod · 0.95
trigger_toolMethod · 0.95

Calls 3

trigger_toolMethod · 0.95
removeMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected