From d0c062d7e59a659c1db8377de5d4afbca04a817d Mon Sep 17 00:00:00 2001 From: KIU Shueng Chuan Date: Fri, 22 Jan 2021 12:30:49 +0800 Subject: [PATCH] Revert "workaround missing setStops binding" This reverts commit c4addbeaeab027d3979968373d0a3ce3abbd8f0f. --- pyqtgraph/colormap.py | 8 +------- pyqtgraph/graphicsItems/GradientEditorItem.py | 8 +------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/pyqtgraph/colormap.py b/pyqtgraph/colormap.py index 741cea08..3661bf75 100644 --- a/pyqtgraph/colormap.py +++ b/pyqtgraph/colormap.py @@ -359,13 +359,7 @@ class ColorMap(object): pos, color = self.getStops(mode=self.BYTE) color = [QtGui.QColor(*x) for x in color] - stops = zip(pos, color) - if hasattr(g, 'setStops'): - g.setStops(list(stops)) - else: - # PySide6 has a missing setStops binding - for pos, col in stops: - g.setColorAt(pos, col) + g.setStops(list(zip(pos, color))) return g def getColors(self, mode=None): diff --git a/pyqtgraph/graphicsItems/GradientEditorItem.py b/pyqtgraph/graphicsItems/GradientEditorItem.py index d763e965..6f5d9132 100644 --- a/pyqtgraph/graphicsItems/GradientEditorItem.py +++ b/pyqtgraph/graphicsItems/GradientEditorItem.py @@ -626,10 +626,9 @@ class GradientEditorItem(TickSliderItem): def getGradient(self): """Return a QLinearGradient object.""" g = QtGui.QLinearGradient(QtCore.QPointF(0,0), QtCore.QPointF(self.length,0)) - stops = [] if self.colorMode == 'rgb': ticks = self.listTicks() - stops = [(x, QtGui.QColor(t.color)) for t,x in ticks] + g.setStops([(x, QtGui.QColor(t.color)) for t,x in ticks]) elif self.colorMode == 'hsv': ## HSV mode is approximated for display by interpolating 10 points between each stop ticks = self.listTicks() stops = [] @@ -642,12 +641,7 @@ class GradientEditorItem(TickSliderItem): x = x1 + dx*j stops.append((x, self.getColor(x))) stops.append((x2, self.getColor(x2))) - if hasattr(g, 'setStops'): g.setStops(stops) - else: - # PySide6 has a missing setStops binding - for pos, col in stops: - g.setColorAt(pos, col) return g def getColor(self, x, toQColor=True):