There's more...

In case you want to translate a color name to the RGB format, you can use the winfo_rgb() method on a previously created widget. Since it returns a tuple of integers from 0 to 65535 to represent a 16-bit RGB value, you can convert it to the more common #RRGGBB hexadecimal representation by shifting 8 bits to the right:

rgb = widget.winfo_rgb("lightblue")
red, green, blue = [x>>8 for x in rgb]
print("#{:02x}{:02x}{:02x}".format(red, green, blue))

In the preceding code, we used {:02x} to format each integer into two hexadecimal numbers.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset