Skip to content

Commit

Permalink
fix issues with the layout-editor in ipympl
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelquast committed Jun 29, 2023
1 parent 0eece67 commit fc276ea
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions eomaps/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,12 +1098,17 @@ def _snap(self):

def _make_draggable(self, filepath=None):
# Uncheck avtive pan/zoom actions of the matplotlib toolbar.
toolbar = getattr(self.m.BM.canvas, "toolbar", None)
if toolbar is not None:
for key in ["pan", "zoom"]:
val = toolbar._actions.get(key, None)
if val is not None and val.isCheckable() and val.isChecked():
val.trigger()
# use a try-except block to avoid issues with ipympl in jupyter notebooks
# (see https://github.com/matplotlib/ipympl/issues/530#issue-1780919042)
try:
toolbar = getattr(self.m.BM.canvas, "toolbar", None)
if toolbar is not None:
for key in ["pan", "zoom"]:
val = toolbar._actions.get(key, None)
if val is not None and val.isCheckable() and val.isChecked():
val.trigger()
except AttributeError:
pass

self._filepath = filepath
self.modifier_pressed = True
Expand Down

0 comments on commit fc276ea

Please sign in to comment.