This article mainly introduces the color space Conversion Program Based on Tkinter using python. If you are interested, refer to this article based on colorsys, for example, converting from hls to rgb, if you want to change the color space, you can easily modify a function. The specific content is as follows:
UsedScale and Canvas Components.
Run:
The Code is as follows:
From Tkinter import * import colorsys # response function def update (* args) after the operation: 'color' r, g, B = colorsys. hls_to_rgb (h. get ()/255.0, l. get ()/255.0, s. get ()/255.0) r, g, B = r * 255, g * 255, B * 255 rgb. configure (text = 'rgb :( % d, % d, % d) '% (r, g, B) c. configure (bg = '# % 02X % 02X % 02x' % (r, g, B) root = Tk () hue = Label (root, text = 'hue ') hue. grid (row = 0, column = 0) light = Label (root, text = 'lightness ') light. grid (row = 0, column = 1) sat = Label (root, text = 'saturation') sat. grid (row = 0, column = 2) # initialize the 000 color of rgb, that is, pure black rgb = Label (root, text = 'rgb (0, 0, 0 )') rgb. grid (row = 0, column = 3) h = Scale (root, from _= 255, to = 0, command = update) h. grid (row = 1, column = 0) l = Scale (root, from _ = 255, to = 0, command = update) l. grid (row = 1, column = 1) s = Scale (root, from _= 255, to = 0, command = update) s. grid (row = 1, column = 2) c = Canvas (root, width = 100, height = 100, bg = 'black') c. grid (row = 1, column = 3) root. mainloop ()
The above is all of the content in this article, hoping to help you learn Python programming.