Skip to content

Commit cc1362a

Browse files
committed
Improve MEP22 Tool Searching Structure
1 parent 18a36a3 commit cc1362a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/matplotlib/backend_managers.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,14 +484,20 @@ def _handle_toggle(self, tool, sender, canvasevent, data):
484484
def _get_cls_to_instantiate(self, callback_class):
485485
# Find the class that corresponds to the tool
486486
if isinstance(callback_class, six.string_types):
487+
try:
488+
backend = self.canvas.manager.backend
489+
except:
490+
backend = get_backend()
491+
487492
# FIXME: make more complete searching structure
488-
if callback_class in globals():
493+
if hasattr(backend, callback_class):
494+
callback_class = getattr(backend, callback_class)
495+
elif callback_class in globals():
489496
callback_class = globals()[callback_class]
490497
else:
491498
mod = 'backend_tools'
492499
current_module = __import__(mod,
493500
globals(), locals(), [mod], -1)
494-
495501
callback_class = getattr(current_module, callback_class, False)
496502
if callable(callback_class):
497503
return callback_class

0 commit comments

Comments
 (0)