From 4699bbad6bb8d3f1d61c09f6035df34b49917286 Mon Sep 17 00:00:00 2001 From: KIU Shueng Chuan Date: Sun, 11 Apr 2021 09:00:52 +0800 Subject: [PATCH] fix keyboard modifiers default value --- pyqtgraph/graphicsItems/ROI.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/pyqtgraph/graphicsItems/ROI.py b/pyqtgraph/graphicsItems/ROI.py index 73a686af..2dcbc759 100644 --- a/pyqtgraph/graphicsItems/ROI.py +++ b/pyqtgraph/graphicsItems/ROI.py @@ -826,10 +826,17 @@ class ROI(GraphicsObject): """ return True - def movePoint(self, handle, pos, modifiers=QtCore.Qt.KeyboardModifiers(0), finish=True, coords='parent'): + def movePoint(self, handle, pos, modifiers=None, finish=True, coords='parent'): ## called by Handles when they are moved. ## pos is the new position of the handle in scene coords, as requested by the handle. - + if modifiers is None: + try: + # this works for PyQt6 6.1 and other bindings + modifiers = QtCore.Qt.KeyboardModifier.NoModifier + except AttributeError: + # this works for PyQt6 6.0 and other bindings + modifiers = QtCore.Qt.KeyboardModifiers(0) + newState = self.stateCopy() index = self.indexOfHandle(handle) h = self.handles[index] @@ -1454,7 +1461,14 @@ class Handle(UIGraphicsItem): self.currentPen = self.hoverPen self.movePoint(pos, ev.modifiers(), finish=False) - def movePoint(self, pos, modifiers=QtCore.Qt.KeyboardModifiers(0), finish=True): + def movePoint(self, pos, modifiers=None, finish=True): + if modifiers is None: + try: + # this works for PyQt6 6.1 and other bindings + modifiers = QtCore.Qt.KeyboardModifier.NoModifier + except AttributeError: + # this works for PyQt6 6.0 and other bindings + modifiers = QtCore.Qt.KeyboardModifiers(0) for r in self.rois: if not r.checkPointMove(self, pos, modifiers): return