Python for Kids by Jason R. Briggs

Python for Kids by Jason R. Briggs

Author:Jason R. Briggs [Jason R. Briggs]
Language: eng
Format: epub, mobi, pdf
Tags: JUVENILE NONFICTION / Computers / Programming
ISBN: 9781593274948
Publisher: No Starch Press
Published: 2012-11-17T16:00:00+00:00


When you select a color and click OK, a tuple will be displayed. This tuple contains another tuple with three numbers and a string:

>>> colorchooser.askcolor() ((235.91796875, 86.3359375, 153.59765625), '#eb5699')

The three numbers represent the amounts of red, green, and blue. In tkinter, the amount of each primary color to use in a color combination is represented by a number between 0 and 255 (which is different from using a percentage for each primary color with the turtle module). The string in the tuple contains the hexadecimal version of those three numbers.

You can either copy and paste the string value to use or store the tuple as a variable, and then use the index position of the hexadecimal value.

Let’s use the random_rectangle function to see how this works.

>>> c = colorchooser.askcolor() >>> random_rectangle(400, 400, c[1])

Here’s the result:



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.