In HTML you can input color using the format: "rgb(255,255,255)" so why not support it here? (Sometimes I want to input a color that is in that format, and don't want to take the effort to convert)
The code could look like this:
@colour.setter
def colour(self, value):
#start of new code
if value[:4] == 'rgb(':
while ' ' in value:
value = value[:value.index(' ')]+value[value.index(' ')+1:]
value = value[4:-1]
r = int(value[:value.index(',')])
value = value[value.index(',')+1:]
g = int(value[:value.index(',')])
value = value[value.index(',')+1:]
b = int(value[:value.index(',')])
value = value[value.index(',')+1:]
value = QtGui.QColor.fromRgb(r,g,b)
#end of new code (other then "elif" rather then "if")
# If this is an integer, assume is RGBA
elif not isinstance(value, QtGui.QColor):
r = (value & 0xff000000) >> 24
g = (value & 0xff0000) >> 16
b = (value & 0xff00) >> 8
value = QtGui.QColor.fromRgb(r,g,b)
self._set_colour(value)
self.RGBvalue.setText(value.name())
self.RGBvalue.setText(value.name())
In HTML you can input color using the format: "rgb(255,255,255)" so why not support it here? (Sometimes I want to input a color that is in that format, and don't want to take the effort to convert)
The code could look like this: