From 385236d4243ee9500a8a7e0494758e8ed4c06e3c Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Mon, 10 Jul 2023 17:16:02 +0200 Subject: [PATCH] Make it work without a plot backend --- src/silx/gui/plot/PlotInteraction.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/silx/gui/plot/PlotInteraction.py b/src/silx/gui/plot/PlotInteraction.py index 616625fd13..fe139b48ce 100644 --- a/src/silx/gui/plot/PlotInteraction.py +++ b/src/silx/gui/plot/PlotInteraction.py @@ -1098,8 +1098,10 @@ def __init__(self, *args, **kw): self._hoverMarker = None def enterState(self): - plot = self.machine.plot - position = plot.getWidgetHandle().mapFromGlobal(qt.QCursor.pos()) + widget = self.machine.plot.getWidgetHandle() + if widget is None or not widget.isVisible(): + return + position = widget.mapFromGlobal(qt.QCursor.pos()) self.onMove(position.x(), position.y()) def onMove(self, x, y): @@ -1342,7 +1344,10 @@ def endDrag(self, startPos, endPos, btn): def cancel(self): self._pan.cancel() - position = self.plot.getWidgetHandle().mapFromGlobal(qt.QCursor.pos()) + widget = self.plot.getWidgetHandle() + if widget is None or not widget.isVisible(): + return + position = widget.mapFromGlobal(qt.QCursor.pos()) self.__terminateDrag(position.x(), position.y())