Skip to content

Commit fc276ea

Browse files
committed
fix issues with the layout-editor in ipympl
(matplotlib/ipympl#530 (comment))
1 parent 0eece67 commit fc276ea

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

eomaps/helpers.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -1098,12 +1098,17 @@ def _snap(self):
10981098

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

11081113
self._filepath = filepath
11091114
self.modifier_pressed = True

0 commit comments

Comments
 (0)