workaround missing setStops binding
This commit is contained in:
parent
b0f7dda102
commit
c4addbeaea
|
@ -359,7 +359,13 @@ class ColorMap(object):
|
||||||
|
|
||||||
pos, color = self.getStops(mode=self.BYTE)
|
pos, color = self.getStops(mode=self.BYTE)
|
||||||
color = [QtGui.QColor(*x) for x in color]
|
color = [QtGui.QColor(*x) for x in color]
|
||||||
g.setStops(list(zip(pos, 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)
|
||||||
return g
|
return g
|
||||||
|
|
||||||
def getColors(self, mode=None):
|
def getColors(self, mode=None):
|
||||||
|
|
|
@ -626,9 +626,10 @@ class GradientEditorItem(TickSliderItem):
|
||||||
def getGradient(self):
|
def getGradient(self):
|
||||||
"""Return a QLinearGradient object."""
|
"""Return a QLinearGradient object."""
|
||||||
g = QtGui.QLinearGradient(QtCore.QPointF(0,0), QtCore.QPointF(self.length,0))
|
g = QtGui.QLinearGradient(QtCore.QPointF(0,0), QtCore.QPointF(self.length,0))
|
||||||
|
stops = []
|
||||||
if self.colorMode == 'rgb':
|
if self.colorMode == 'rgb':
|
||||||
ticks = self.listTicks()
|
ticks = self.listTicks()
|
||||||
g.setStops([(x, QtGui.QColor(t.color)) for t,x in ticks])
|
stops = [(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
|
elif self.colorMode == 'hsv': ## HSV mode is approximated for display by interpolating 10 points between each stop
|
||||||
ticks = self.listTicks()
|
ticks = self.listTicks()
|
||||||
stops = []
|
stops = []
|
||||||
|
@ -641,7 +642,12 @@ class GradientEditorItem(TickSliderItem):
|
||||||
x = x1 + dx*j
|
x = x1 + dx*j
|
||||||
stops.append((x, self.getColor(x)))
|
stops.append((x, self.getColor(x)))
|
||||||
stops.append((x2, self.getColor(x2)))
|
stops.append((x2, self.getColor(x2)))
|
||||||
|
if hasattr(g, 'setStops'):
|
||||||
g.setStops(stops)
|
g.setStops(stops)
|
||||||
|
else:
|
||||||
|
# PySide6 has a missing setStops binding
|
||||||
|
for pos, col in stops:
|
||||||
|
g.setColorAt(pos, col)
|
||||||
return g
|
return g
|
||||||
|
|
||||||
def getColor(self, x, toQColor=True):
|
def getColor(self, x, toQColor=True):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user