Python implements the color space Conversion Program (Tkinter), pythontkinter

Source: Internet
Author: User

Python implements the color space Conversion Program (Tkinter), pythontkinter

This article is mainly implemented based on colorsys. The example is to convert from hls to rgb. If you want to change the color space, you only need to modify one 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.

Articles you may be interested in:
  • Python3 uses tkinter to implement a simple ui instance
  • How does python output color-coded text in linux?
  • Python tkinter Layout-Simple Chat Window implementation
  • Python Tkinter simple layout example tutorial
  • Python Tkinter basic control usage
  • Use the Tkinter module in Python to create GUI program instances
  • Python implements color rgb and hex conversion functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.