Skip to content

Commit

Permalink
Improve MEP22 Tool Searching Structure
Browse files Browse the repository at this point in the history
  • Loading branch information
OceanWolf committed Jun 25, 2015
1 parent 18a36a3 commit 6d379bc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/matplotlib/backend_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,13 +485,15 @@ def _get_cls_to_instantiate(self, callback_class):
# Find the class that corresponds to the tool
if isinstance(callback_class, six.string_types):
# FIXME: make more complete searching structure
if callback_class in globals():
if hasattr(self.canvas, 'manager') and \
hasattr(self.canvas.manager.backend, callback_class):
callback_class = getattr(self.canvas.manager.backend, callback_class)
elif callback_class in globals():
callback_class = globals()[callback_class]
else:
mod = 'backend_tools'
current_module = __import__(mod,
globals(), locals(), [mod], -1)

callback_class = getattr(current_module, callback_class, False)
if callable(callback_class):
return callback_class
Expand Down

0 comments on commit 6d379bc

Please sign in to comment.