Skip to content

Instantly share code, notes, and snippets.

@Carreau
Created February 21, 2022 14:37
Show Gist options
  • Save Carreau/283d6d3275b371bfaff58146f72cdae9 to your computer and use it in GitHub Desktop.
Save Carreau/283d6d3275b371bfaff58146f72cdae9 to your computer and use it in GitHub Desktop.
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
File ~/miniconda3-intel/envs/napari/lib/python3.9/site-packages/vispy/app/backends/_qt.py:512, in QtBaseCanvasBackend.mouseReleaseEvent(self=<vispy.app.backends._qt.CanvasBackendDesktop object>, ev=<PyQt5.QtGui.QMouseEvent object>)
510 if self._vispy_canvas is None:
511 return
--> 512 self._vispy_mouse_release(
self = <vispy.app.backends._qt.CanvasBackendDesktop object at 0x7fb2419960d0>
ev = <PyQt5.QtGui.QMouseEvent object at 0x7fb254e5f790>
BUTTONMAP = {0: 0, 1: 1, 2: 2, 4: 3, 8: 4, 16: 5}
513 native=ev,
514 pos=_get_event_xy(ev),
515 button=BUTTONMAP[ev.button()],
516 modifiers=self._modifiers(ev),
517 )
File ~/miniconda3-intel/envs/napari/lib/python3.9/site-packages/vispy/app/base.py:224, in BaseCanvasBackend._vispy_mouse_release(self=<vispy.app.backends._qt.CanvasBackendDesktop object>, **kwargs={'button': 1, 'buttons': [1], 'last_event': <MouseEvent blocked=False button=1 buttons=[1] d...rces=[] time=1645454132.6820524 type=mouse_press>, 'last_mouse_press': None, 'modifiers': (), 'native': <PyQt5.QtGui.QMouseEvent object>, 'pos': (268, 188), 'press_event': <MouseEvent blocked=False button=1 buttons=[1] d...rces=[] time=1645454132.6820524 type=mouse_press>})
220 def _vispy_mouse_release(self, **kwargs):
221 # default method for delivering mouse release events to the canvas
222 kwargs.update(self._vispy_mouse_data)
--> 224 ev = self._vispy_canvas.events.mouse_release(**kwargs)
self._vispy_canvas.events.mouse_release = <vispy.util.event.EventEmitter object at 0x7fb24198c370>
kwargs = {'native': <PyQt5.QtGui.QMouseEvent object at 0x7fb254e5f790>, 'pos': (268, 188), 'button': 1, 'modifiers': (), 'buttons': [1], 'press_event': <MouseEvent blocked=False button=1 buttons=[1] delta=[0. 0.] handled=False is_dragging=False last_event=MouseEvent modifiers=() native=<PyQt5.QtGui.QMouseEvent object at 0x7fb254e5f790> pos=[268 188] press_event=None source=None sources=[] time=1645454132.6820524 type=mouse_press>, 'last_event': <MouseEvent blocked=False button=1 buttons=[1] delta=[0. 0.] handled=False is_dragging=False last_event=MouseEvent modifiers=() native=<PyQt5.QtGui.QMouseEvent object at 0x7fb254e5f790> pos=[268 188] press_event=None source=None sources=[] time=1645454132.6820524 type=mouse_press>, 'last_mouse_press': None}
self = <vispy.app.backends._qt.CanvasBackendDesktop object at 0x7fb2419960d0>
self._vispy_canvas.events = <vispy.util.event.EmitterGroup object at 0x7fb24198c280>
self._vispy_canvas = <VispyCanvas (PyQt5) at 0x7fb253a71e20>
225 if (self._vispy_mouse_data['press_event']
226 and self._vispy_mouse_data['press_event'].button == ev.button):
227 self._vispy_mouse_data['press_event'] = None
File ~/miniconda3-intel/envs/napari/lib/python3.9/site-packages/vispy/util/event.py:453, in EventEmitter.__call__(self=<vispy.util.event.EventEmitter object>, *args=(), **kwargs={'button': 1, 'buttons': [1], 'last_event': <MouseEvent blocked=False button=1 buttons=[1] d...rces=[] time=1645454132.6820524 type=mouse_press>, 'last_mouse_press': None, 'modifiers': (), 'native': <PyQt5.QtGui.QMouseEvent object>, 'pos': (268, 188), 'press_event': <MouseEvent blocked=False button=1 buttons=[1] d...rces=[] time=1645454132.6820524 type=mouse_press>})
450 if self._emitting > 1:
451 raise RuntimeError('EventEmitter loop detected!')
--> 453 self._invoke_callback(cb, event)
event = <MouseEvent blocked=False button=1 buttons=[1] delta=[0. 0.] handled=False is_dragging=True last_event=MouseEvent modifiers=() native=<PyQt5.QtGui.QMouseEvent object at 0x7fb254e5f790> pos=[268 188] press_event=MouseEvent source=None sources=[] time=1645454132.7731786 type=mouse_release>
self = <vispy.util.event.EventEmitter object at 0x7fb24198c370>
cb = <bound method QtViewer.on_mouse_release of <napari._qt.qt_viewer.QtViewer object at 0x7fb2301393a0>>
454 if event.blocked:
455 break
File ~/miniconda3-intel/envs/napari/lib/python3.9/site-packages/vispy/util/event.py:471, in EventEmitter._invoke_callback(self=<vispy.util.event.EventEmitter object>, cb=<bound method QtViewer.on_mouse_release of <napari._qt.qt_viewer.QtViewer object>>, event=<MouseEvent blocked=False button=1 buttons=[1] d...es=[] time=1645454132.7731786 type=mouse_release>)
469 cb(event)
470 except Exception:
--> 471 _handle_exception(self.ignore_callback_errors,
self = <vispy.util.event.EventEmitter object at 0x7fb24198c370>
cb = <bound method QtViewer.on_mouse_release of <napari._qt.qt_viewer.QtViewer object at 0x7fb2301393a0>>
event = <MouseEvent blocked=False button=1 buttons=[1] delta=[0. 0.] handled=False is_dragging=True last_event=MouseEvent modifiers=() native=<PyQt5.QtGui.QMouseEvent object at 0x7fb254e5f790> pos=[268 188] press_event=MouseEvent source=None sources=[] time=1645454132.7731786 type=mouse_release>
(cb, event) = (<bound method QtViewer.on_mouse_release of <napari._qt.qt_viewer.QtViewer object at 0x7fb2301393a0>>, <MouseEvent blocked=False button=1 buttons=[1] delta=[0. 0.] handled=False is_dragging=True last_event=MouseEvent modifiers=() native=<PyQt5.QtGui.QMouseEvent object at 0x7fb254e5f790> pos=[268 188] press_event=MouseEvent source=None sources=[] time=1645454132.7731786 type=mouse_release>)
472 self.print_callback_errors,
473 self, cb_event=(cb, event))
File ~/miniconda3-intel/envs/napari/lib/python3.9/site-packages/vispy/util/event.py:469, in EventEmitter._invoke_callback(self=<vispy.util.event.EventEmitter object>, cb=<bound method QtViewer.on_mouse_release of <napari._qt.qt_viewer.QtViewer object>>, event=<MouseEvent blocked=False button=1 buttons=[1] d...es=[] time=1645454132.7731786 type=mouse_release>)
467 def _invoke_callback(self, cb, event):
468 try:
--> 469 cb(event)
cb = <bound method QtViewer.on_mouse_release of <napari._qt.qt_viewer.QtViewer object at 0x7fb2301393a0>>
event = <MouseEvent blocked=False button=1 buttons=[1] delta=[0. 0.] handled=False is_dragging=True last_event=MouseEvent modifiers=() native=<PyQt5.QtGui.QMouseEvent object at 0x7fb254e5f790> pos=[268 188] press_event=MouseEvent source=None sources=[] time=1645454132.7731786 type=mouse_release>
470 except Exception:
471 _handle_exception(self.ignore_callback_errors,
472 self.print_callback_errors,
473 self, cb_event=(cb, event))
File ~/dev/napari/napari/_qt/qt_viewer.py:970, in QtViewer.on_mouse_release(self=<napari._qt.qt_viewer.QtViewer object>, event=<MouseEvent blocked=False button=1 buttons=[1] d...es=[] time=1645454132.7731786 type=mouse_release>)
962 def on_mouse_release(self, event):
963 """Called whenever mouse released in canvas.
964
965 Parameters
(...)
968 The vispy event that triggered this method.
969 """
--> 970 self._process_mouse_event(mouse_release_callbacks, event)
event = <MouseEvent blocked=False button=1 buttons=[1] delta=[0. 0.] handled=False is_dragging=True last_event=MouseEvent modifiers=() native=<PyQt5.QtGui.QMouseEvent object at 0x7fb254e5f790> pos=[268 188] press_event=MouseEvent source=None sources=[] time=1645454132.7731786 type=mouse_release>
self = <napari._qt.qt_viewer.QtViewer object at 0x7fb2301393a0>
File ~/dev/napari/napari/_qt/qt_viewer.py:909, in QtViewer._process_mouse_event(self=<napari._qt.qt_viewer.QtViewer object>, mouse_callbacks=<function mouse_release_callbacks>, event=<ReadOnlyWrapper at 0x7fb25513da00 for MouseEvent>)
907 layer = self.viewer.layers.selection.active
908 if layer is not None:
--> 909 mouse_callbacks(layer, event)
event = <ReadOnlyWrapper at 0x7fb25513da00 for MouseEvent at 0x7fb255149ee0>
layer = <Labels layer 'Labels' at 0x7fb2423a6460>
mouse_callbacks = <function mouse_release_callbacks at 0x7fb2522d8790>
File ~/dev/napari/napari/utils/interactions.py:211, in mouse_release_callbacks(obj=<Labels layer 'Labels'>, event=<ReadOnlyWrapper at 0x7fb25513da00 for MouseEvent>)
208 obj._persisted_mouse_event[gen].__wrapped__ = event
209 try:
210 # Run last part of the function to trigger release event
--> 211 next(gen)
gen = <generator object draw at 0x7fb2423a4f20>
212 except StopIteration:
213 pass
File ~/dev/napari/napari/layers/labels/_labels_mouse_bindings.py:77, in draw(layer=<Labels layer 'Labels'>, event=<ReadOnlyWrapper at 0x7fb25515f7c0 for ReadOnlyWrapper>)
75 # on release
76 layer._block_saving = False
---> 77 undo_item = layer._undo_history[-1]
layer = <Labels layer 'Labels' at 0x7fb2423a6460>
layer._undo_history = deque([], maxlen=100)
78 if len(undo_item) == 1 and len(undo_item[0][0][0]) == 0:
79 layer._undo_history.pop()
IndexError: deque index out of range
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment