I hope someone can help me understand dealing with RGB colours in the ui module. When I set an attribute using a so called RGB color, it does not seem to work as I would expect. In my example below, I looked up the CSS color lightcoral on the net. I got the corresponding values for the hex and RGB Values. As you can see I try to apply the different types of values to the background color of a button. I don't understand the results. I have worked on this for some hours, so frustrating, is probably so simple. Any advice, appreciated. Oh, the reason why I want to get the RGB values working/understanding, is because I was reading an answer on stackflow about how to programmatically create shades and tints from RGB components. Looks great.
import ui
color_modes = [
#RGBA as truple
(240.0,128.0,128.0, 1.0),
#RGBA as string
"240.0,128.0,128.0, 1.0",
#RGB as truple
(240,128,128),
#CSS Color
'lightcoral',
#CSS Color as Hex
'#F08080',
#the RGBA truple after i printed it out from CSS Color lightcoral, then pasted it into the truple here
(0.9411759972572327, 0.5019609928131104, 0.5019609928131104, 1),
#as above but represented as a string
"(0.9411759972572327, 0.5019609928131104, 0.5019609928131104, 1)",
]
_pad = 10
def std_btn(title = ''):
btn = ui.Button(title = title)
btn.border_color = 'black'
btn.border_width = 1
btn.height = 64
btn.width = 540
btn.font = ('<System>', 14)
btn.tint_color = 'green'
return btn
if __name__ == '__main__':
v = ui.View(name = 'lightcoral CSS color background test')
for i in range(0,len(color_modes)):
btn = std_btn('button' + str(i +1) + ' ' + str(color_modes[i]))
btn.y = (btn.height * i) + (i * _pad)
btn.background_color = color_modes[i]
v.add_subview(btn)
v.background_color ='white'
v.present('sheet')