def setColor(self, r, g, b):
"""
:param r: red, integer 0-255
:param g: green, integer 0-255
:param b: blue, integer 0-255
:return: None
"""
self.updateEnabled = False
if self.colorModeLocal == 1: # hsv
col = [ int(round(x*255)) for x in colorsys.rgb_to_hsv(float(r)/255,float(g)/255,float(b)/255)]
self.colorX.set(col[0])
self.colorY.set(col[1])
self.colorZ.set(col[2])
self.colorSwatch.itemconfig(self.crect, fill='#%02x%02x%02x'%(r, g, b))
else: # RGB
self.colorX.set(r)
self.colorY.set(g)
self.colorZ.set(b)
self.colorSwatch.itemconfig(self.crect, fill='#%02x%02x%02x'%(r, g, b))
self.updateEnabled = True
评论列表
文章目录