22.07.2013 Views

A Comprehensive Introduction to Python Programming and ... - MSDL

A Comprehensive Introduction to Python Programming and ... - MSDL

A Comprehensive Introduction to Python Programming and ... - MSDL

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

5.1 Specifying colors<br />

5<br />

Tkinter-specific Topics<br />

Tkinter defines several color names that can be easily used as color values in <strong>Python</strong><br />

programs. These color names are taken from the names that are provided by X Windows.<br />

The complete list is prodided in Appendix A on page 55. For a more precise<br />

description of colors, Tkinter allows the use of color strings. These strings start with a<br />

number sign (#) <strong>and</strong> specify the precise values of the red, green <strong>and</strong> blue components<br />

of the color. There are three forms of color strings, depending on how many levels each<br />

component is allowed:<br />

#RGB : 4-bit components (12 bits <strong>to</strong>tal), 16 levels per component.<br />

#RRGGBB : 8-bit components (24 bits <strong>to</strong>tal), 256 levels pre component.<br />

#RRRRGGGGBBBB : 16-bit components, (48 bits <strong>to</strong>tal), 65536 levels per component.<br />

R, G <strong>and</strong> B are single hexadecimal digits (0..F, or 0..f).<br />

For example, “#F00”, “#FF0000” <strong>and</strong> “#FFFF00000000” all specify a pure red<br />

color. Similarly, “#48A”, “#4080A0” <strong>and</strong> “#40008000A000” represent the same color.<br />

5.2 Specifying Fonts<br />

Tkinter provides several ways of defining fonts. It provides font descrip<strong>to</strong>rs that are<br />

easier <strong>to</strong> work with than the very precise but <strong>to</strong>o confusing X Window System font<br />

descrip<strong>to</strong>r. X Window System font descrip<strong>to</strong>rs are still supported, but they will not be<br />

discussed here since they should be rarely needed. There are two other major kinds of<br />

font descrip<strong>to</strong>rs that are available: in Tkinter:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!