1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>gtk.gdk.Color</title><link rel="stylesheet" href="style.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"><link rel="start" href="index.html" title="PyGTK 2.0 Reference Manual"><link rel="up" href="gdk-class-reference.html" title="The gtk.gdk Class Reference"><link rel="prev" href="class-gdkcairocontext.html" title="gtk.gdk.CairoContext"><link rel="next" href="class-gdkcolormap.html" title="gtk.gdk.Colormap"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">gtk.gdk.Color</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="class-gdkcairocontext.html">Prev</a> </td><th width="60%" align="center">The gtk.gdk Class Reference</th><td width="20%" align="right"> <a accesskey="n" href="class-gdkcolormap.html">Next</a></td></tr></table><hr></div><div class="refentry" lang="en"><a name="class-gdkcolor"></a><div class="titlepage"></div><div class="refnamediv"><h2>gtk.gdk.Color</h2><p>gtk.gdk.Color — an object holding color information</p></div><div class="refsect1" lang="en"><a name="id2999648"></a><h2>Synopsis</h2><table bgcolor="#D0E0F0" width="100%"><tr><td><pre class="classsynopsis">class <span class="ooclass"><span class="classname">gtk.gdk.Color</span></span>(<span class="ooclass"><span class="classname">gobject.GBoxed</span></span>):
<code class="constructorsynopsis"> <span class="methodname"><a class="link" href="class-gdkcolor.html#constructor-gdkcolor" title="Constructor">gtk.gdk.Color</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>red</code></strong></span><span class="initializer">=0</span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>green</code></strong></span><span class="initializer">=0</span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>blue</code></strong></span><span class="initializer">=0</span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>pixel</code></strong></span><span class="initializer">=0</span></span>)</code><br><code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gdkcolor.html#method-gdkcolor--to-string" title="gtk.gdk.Color.to_string">to_string</a></span>(<span class="methodparam"></span>)</code><br></pre></td></tr></table><pre class="programlisting">
<span class="bold"><strong>Functions</strong></span>
<code class="methodsynopsis"> def <span class="methodname"><a class="link" href="class-gdkcolor.html#function-gdk--color-parse" title="gtk.gdk.color_parse">gtk.gdk.color_parse</a></span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>spec</code></strong></span></span>)</code></pre></div><div class="refsect1" lang="en"><a name="id2999500"></a><h2>Attributes</h2><div class="blockquote"><table width="100%" border="0" bgcolor="#E0E0E0"><tr><td valign="top"><div class="informaltable"><table cellpadding="5" width="100%" border="0"><colgroup><col><col><col></colgroup><tbody><tr valign="top"><td valign="top">"pixel"</td><td valign="top">Read-Write</td><td valign="top">The pixel value of the color</td></tr><tr valign="top"><td valign="top">"red"</td><td valign="top">Read-Write</td><td valign="top">The value of the red component of the color</td></tr><tr valign="top"><td valign="top">"green"</td><td valign="top">Read-Write</td><td valign="top">The value of the green component of the color</td></tr><tr valign="top"><td valign="top">"blue"</td><td valign="top">Read-Write</td><td valign="top">The value of the blue component of the color</td></tr></tbody></table></div></td></tr></table></div></div><div class="refsect1" lang="en"><a name="id2999379"></a><h2>Description</h2><p>A <a class="link" href="class-gdkcolor.html" title="gtk.gdk.Color"><code class="classname">gtk.gdk.Color</code></a>
contains the values of a color that may or may not be allocated. The red,
green and blue attributes are specified by an unsigned integer in the range
0-65535. The pixel value is an index into the colormap that has allocated
the <a class="link" href="class-gdkcolor.html" title="gtk.gdk.Color"><code class="classname">gtk.gdk.Color</code></a>.
Typically a color is allocated by using the <a class="link" href="class-gdkcolormap.html#method-gdkcolormap--alloc-color" title="gtk.gdk.Colormap.alloc_color"><code class="methodname">gdk.Colormap.alloc_color</code>()</a>
method. Unallocated colors can be used to specify the color attributes of
<a class="link" href="class-gtkstyle.html" title="gtk.Style"><code class="classname">gtk.Style</code></a>
objects since these colors will be allocated when an attempt is made to use
the <a class="link" href="class-gtkstyle.html" title="gtk.Style"><code class="classname">gtk.Style</code></a>
object.</p></div><div class="refsect1" lang="en"><a name="constructor-gdkcolor"></a><h2>Constructor</h2><pre class="programlisting"><code class="constructorsynopsis"> <span class="methodname">gtk.gdk.Color</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>red</code></strong></span><span class="initializer">=0</span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>green</code></strong></span><span class="initializer">=0</span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>blue</code></strong></span><span class="initializer">=0</span></span>, <span class="methodparam"><span class="parameter"><strong class="parameter"><code>pixel</code></strong></span><span class="initializer">=0</span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>red</code></strong> :</span></p></td><td>The red color component in the range
0-65535</td></tr><tr><td><p><span class="term"><strong class="parameter"><code>green</code></strong> :</span></p></td><td>The green color component in the range
0-65535</td></tr><tr><td><p><span class="term"><strong class="parameter"><code>blue</code></strong> :</span></p></td><td>The blue color component in the range
0-65535</td></tr><tr><td><p><span class="term"><strong class="parameter"><code>pixel</code></strong> :</span></p></td><td>The index of the color when allocated in its
colormap</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>a new <a class="link" href="class-gdkcolor.html" title="gtk.gdk.Color"><code class="classname">gtk.gdk.Color</code></a>
object</td></tr></tbody></table><p>Creates a new <a class="link" href="class-gdkcolor.html" title="gtk.gdk.Color"><code class="classname">gtk.gdk.Color</code></a> object
with the color component values specified by <em class="parameter"><code>red</code></em>,
<em class="parameter"><code>green</code></em> and <em class="parameter"><code>blue</code></em> (all default to
0) and using the pixel value specified by <em class="parameter"><code>pixel</code></em>. The
value of <em class="parameter"><code>pixel</code></em> will be overwritten when the color is
allocated.</p></div><div class="refsect1" lang="en"><a name="id2881510"></a><h2>Methods</h2><div class="refsect2" lang="en"><a name="method-gdkcolor--to-string"></a><h3>gtk.gdk.Color.to_string</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">to_string</span>(<span class="methodparam"></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>a string</td></tr></tbody></table><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>This method is available in PyGTK 2.12 and above.</p></div><p>
The <code class="methodname">to_string</code>() method returns a textual
specification of color in the hexadecimal form #rrrrggggbbbb,
where r, g and b are hex digits representing the red,
green and blue components respectively.
</p></div></div><div class="refsect1" lang="en"><a name="id2881434"></a><h2>Functions</h2><div class="refsect2" lang="en"><a name="function-gdk--color-parse"></a><h3>gtk.gdk.color_parse</h3><pre class="programlisting"><code class="methodsynopsis"> def <span class="methodname">gtk.gdk.color_parse</span>(<span class="methodparam"><span class="parameter"><strong class="parameter"><code>spec</code></strong></span></span>)</code></pre><table border="0" width="100%" bgcolor="#FFECCE"><col align="left" valign="top" width="0*"><tbody><tr><td><p><span class="term"><strong class="parameter"><code>spec</code></strong> :</span></p></td><td>a string containing a color
specification</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td>a <a class="link" href="class-gdkcolor.html" title="gtk.gdk.Color"><code class="classname">gtk.gdk.Color</code></a>
object</td></tr></tbody></table><p>The <code class="function">gtk.gdk.color_parse</code>() method returns
the <a class="link" href="class-gdkcolor.html" title="gtk.gdk.Color"><code class="classname">gtk.gdk.Color</code></a>
specified by <em class="parameter"><code>spec</code></em>. The format of
<em class="parameter"><code>spec</code></em> is a string containing the specification of the
color either as a name (e.g. "navajowhite") as specified in the X11
<code class="filename">rgb.txt</code> file or as a hexadecimal string (e.g.
"#FF0078"). The hexadecimal string must start with '#' and must contain 3
sets of hexadecimal digits of the same length (i.e. 1, 2 ,3 or 4 digits).
For example the following specify the same color value: "#F0A", "#FF00AA",
"#FFF000AAA" and "#FFFF0000AAAA". The <a class="link" href="class-gdkcolor.html" title="gtk.gdk.Color"><code class="classname">gtk.gdk.Color</code></a> is
<span class="emphasis"><em>not</em></span> allocated.</p><p>This function raise the ValueError (TypeError prior to PyGTK
2.4) exception if unable to parse the color specification</p></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="class-gdkcairocontext.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="gdk-class-reference.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="class-gdkcolormap.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">gtk.gdk.CairoContext </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> gtk.gdk.Colormap</td></tr></table></div></body></html>
|