Skip to content

Commit b619923

Browse files
OceanWolftacaswell
authored andcommitted
Improve MEP22 Tool Searching Structure
1 parent 92de15e commit b619923

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
@@ -529,14 +529,20 @@ def _handle_toggle(self, tool, sender, canvasevent, data):
529529
def _get_cls_to_instantiate(self, callback_class):
530530
# Find the class that corresponds to the tool
531531
if isinstance(callback_class, six.string_types):
532+
try:
533+
backend = self.canvas.manager.backend
534+
except:
535+
backend = get_backend()
536+
532537
# FIXME: make more complete searching structure
533-
if callback_class in globals():
538+
if hasattr(backend, callback_class):
539+
callback_class = getattr(backend, callback_class)
540+
elif callback_class in globals():
534541
callback_class = globals()[callback_class]
535542
else:
536543
mod = 'backend_tools'
537544
current_module = __import__(mod,
538545
globals(), locals(), [mod], 1)
539-
540546
callback_class = getattr(current_module, callback_class, False)
541547
if callable(callback_class):
542548
return callback_class

0 commit comments

Comments
 (0)