MCPcopy Create free account
hub / github.com/ColdGrub1384/Pyto / _handle_toggle

Method _handle_toggle

site-packages/matplotlib/backend_managers.py:295–338  ·  view source on GitHub ↗

Toggle tools, need to untoggle prior to using other Toggle tool Called from trigger_tool Parameters ---------- tool: Tool object sender: object Object that wishes to trigger the tool canvasevent : Event Original Canvas

(self, tool, sender, canvasevent, data)

Source from the content-addressed store, hash-verified

293 self._callbacks.process(s, event)
294
295 def _handle_toggle(self, tool, sender, canvasevent, data):
296 """
297 Toggle tools, need to untoggle prior to using other Toggle tool
298 Called from trigger_tool
299
300 Parameters
301 ----------
302 tool: Tool object
303 sender: object
304 Object that wishes to trigger the tool
305 canvasevent : Event
306 Original Canvas event or None
307 data : Object
308 Extra data to pass to the tool when triggering
309 """
310
311 radio_group = tool.radio_group
312 # radio_group None is not mutually exclusive
313 # just keep track of toggled tools in this group
314 if radio_group is None:
315 if tool.name in self._toggled[None]:
316 self._toggled[None].remove(tool.name)
317 else:
318 self._toggled[None].add(tool.name)
319 return
320
321 # If the tool already has a toggled state, untoggle it
322 if self._toggled[radio_group] == tool.name:
323 toggled = None
324 # If no tool was toggled in the radio_group
325 # toggle it
326 elif self._toggled[radio_group] is None:
327 toggled = tool.name
328 # Other tool in the radio_group is toggled
329 else:
330 # Untoggle previously toggled tool
331 self.trigger_tool(self._toggled[radio_group],
332 self,
333 canvasevent,
334 data)
335 toggled = tool.name
336
337 # Keep track of the toggled tool in the radio_group
338 self._toggled[radio_group] = toggled
339
340 def _get_cls_to_instantiate(self, callback_class):
341 # Find the class that corresponds to the tool

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