File: Color.html

package info (click to toggle)
python-pmw 0.8.5-6
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,820 kB
  • ctags: 3,468
  • sloc: python: 14,898; makefile: 37; sh: 17
file content (234 lines) | stat: -rw-r--r-- 8,813 bytes parent folder | download
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234

    <html>
    <head>
    <meta name="description" content="Pmw - a toolkit for building high-level compound widgets in Python">
    <meta name="content" content="python, megawidget, mega widget, compound widget, gui, tkinter">
    <title>Pmw.Color reference manual</title>
    </head>

    <body bgcolor="#ffffff" text="#000000" link="#0000ee"
	vlink="551a8b" alink="ff0000">

    <h1 ALIGN="CENTER">Pmw.Color</h1>
    <p>
    
<dl>
<dt> <h3>Description</h3><dd>
<p>
    This is a set of functions for manipulating colors and for
    modifying the color scheme of an application or a widget.
    Colors can be represented in a number of ways:</p>
<dl><dt><strong>name</strong><dd>a standard color name, eg <code>'orange'</code> or <code>'#ffa500'</code></p>


<dt><strong>rgb</strong><dd>a 3-element sequence of red, green and blue intensities
        each between 0.0 (dark) and 1.0 (light), eg <code>[1.0, 0.6, 0.0]</code>.</p>


<dt><strong>hsi</strong><dd>a 3-element sequence (<em>hue</em>, <em>saturation</em>,
        <em>intensity</em>).  The value of <em>hue</em> is between 0.0 and <strong>2pi</strong>
        (6.28318) giving a range of colors covering, in order, red,
        orange, yellow green, cyan, blue, magenta and back to red. 
        The value of <em>saturation</em> is between 0.0 (grey) and 1.0
        (brilliant) and the value of <em>intensity</em> is between 0.0 (dark)
        and 1.0 (bright).</p>

</dl>

<p>    <strong>brightness</strong> As used in these functions, the brightness of a color
    is the brightness as registered by the human eye.  For example,
    even though the colors red, blue and yellow have the same
    intensity (1.0), they have different brightnesses, 0.299, 0.114
    and 0.886 respectively, reflecting the different way these colors
    appear to the eye.  The brightness of a color is a value between
    0.0 (dark) and 1.0 (bright).</p>

<p>    <strong>color scheme</strong> A color scheme is a set of colors defined for each
    of the default color options in the Tk option database.  Color
    schemes can be used in two ways.  Firstly, using
    <code>Pmw.Color.setscheme()</code>, the Tk option database can be set to the
    values in the color scheme.  This will not have any effect on
    currently existing widgets, but any new widgets created after
    setting the options will have these colors as their defaults. 
    Secondly, using <code>Pmw.Color.changecolor()</code> the color scheme can be
    used to change the colors of a widget and all its child widgets.</p>

<p>    A color scheme is specified by defining one or more color options
    (one of the defined options must be <code>background</code>).  Not all
    options need be specified - if any options are not defined, they
    are calculated from the other colors.  These are the options used
    by a color scheme, together with their values if not specified:</p>
<dl><dd><pre> background:            (must be specified)
 foreground:            black
 activeForeground:      same as foreground
 insertBackground:      same as foreground
 selectForeground:      same as foreground
 highlightColor:        same as foreground
 disabledForeground:    between fg and bg but closer to bg
 highlightBackground:   same as background
 activeBackground:      a little lighter that bg
 selectBackground:      a little darker that bg
 troughColor:           a little darker that bg
 selectColor:           yellow</pre></dl>


<p></p>


<dt> <h3>Functions</h3><dd>
The following functions are available.<p>
<dl>
<dt> <strong>Pmw.Color.average</strong>(<em>col1</em>, <em>col2</em>, <em>fraction</em>)<dd>
<p></p>
</dt>
<dt> <strong>Pmw.Color.bordercolors</strong>(<em>root</em>, <em>color</em>)<dd>
<p></p>
</dt>
<dt> <strong>Pmw.Color.changebrightness</strong>(<em>root</em>, <em>colorName</em>, <em>brightness</em>)<dd>

    Find the hue of the color <em>colorName</em> and return a color of this
    hue with the required <em>brightness</em>.</p>

<p></p>


</dt>
<dt> <strong>Pmw.Color.changecolor</strong>(<em>widget</em>, <em>background</em> = <strong>None</strong>, **<em>kw</em>)<dd>

    Change the color of <em>widget</em> and all its child widgets according
    to the color scheme specified by the other arguments.  This is done
    by modifying all of the color options of existing widgets that
    have the default value.  The color options are the lower case
    versions of those described in the <strong>color scheme</strong> section.  Any
    options which are different to the previous color scheme (or the
    defaults, if this is the first call) are not changed.</p>

<p>    For example to change a widget to have a red color scheme with a
    white foreground:</p>

<dl><dd><pre> Pmw.Color.changecolor(widget,
     background = 'red3', foreground = 'white')</pre></dl>

<p>    The colors of widgets created after this call will not be
    affected.</p>

<p>    Note that <em>widget</em> must be a Tk widget or toplevel.  To change the
    color of a Pmw megawidget, use it's <strong>hull</strong> component.  For example:</p>

<dl><dd><pre> widget = megawidget.component('hull')
 Pmw.Color.changecolor(widget, background = 'red3')</pre></dl>

<p></p>


</dt>
<dt> <strong>Pmw.Color.correct</strong>(<em>rgb</em>, <em>correction</em>)<dd>
<p></p>
</dt>
<dt> <strong>Pmw.Color.getdefaultpalette</strong>(<em>root</em>)<dd>

    Return a dictionary of the default values of the color options
    described in the <strong>color scheme</strong> section.</p>

<p>    To do this, a few widgets are created as children of <em>root</em>, their
    defaults are queried, and then the widgets are destroyed.  (Tk
    supplies no other way to get widget default values.)</p>

<p>    Note that <em>root</em> must be a Tk widget or toplevel.  To use a Pmw
    megawidget as the root, use it's <strong>hull</strong> component.  For example:</p>

<dl><dd><pre> root = megawidget.component('hull')
 Pmw.Color.getdefaultpalette(root)</pre></dl>

<p></p>


</dt>
<dt> <strong>Pmw.Color.hsi2rgb</strong>(<em>hue</em>, <em>saturation</em>, <em>intensity</em>)<dd>

    Return a list of <strong>rgb</strong> values of the color corresponding to <em>hue</em>,
    <em>saturation</em> and <em>intensity</em>.</p>

<p></p>


</dt>
<dt> <strong>Pmw.Color.hsi2saturation</strong>(<em>brightness</em>, <em>h</em>, <em>i</em>)<dd>
<p></p>
</dt>
<dt> <strong>Pmw.Color.hue2name</strong>(<em>hue</em>, <em>brightness</em> = <strong>None</strong>)<dd>

    Return the color with the specified <em>hue</em> and <em>brightness</em>.  If
    <em>hue</em> is <strong>None</strong>, return a grey of the requested brightness. 
    Otherwise, the value of <em>hue</em> should be as described above.</p>

<p></p>


</dt>
<dt> <strong>Pmw.Color.rgb2brightness</strong>(<em>rgb</em>)<dd>
<p></p>
</dt>
<dt> <strong>Pmw.Color.rgb2hsi</strong>(<em>rgb</em>)<dd>

    Return a tuple (<em>hue</em>, <em>saturation</em>, <em>intensity</em>) corresponding to
    the color specified by the <em>rgb</em> sequence.</p>

<p></p>


</dt>
<dt> <strong>Pmw.Color.rgb2name</strong>(<em>rgb</em>)<dd>
<p></p>
</dt>
<dt> <strong>Pmw.Color.setscheme</strong>(<em>root</em>, <em>background</em> = <strong>None</strong>, **<em>kw</em>)<dd>

    Set the color scheme for the application by setting default colors
    (in the Tk option database of the root window of <em>root</em>) according
    to the color scheme specified by the other arguments.</p>

<p>    For example to initialise an application to have a red color
    scheme with a white foreground:</p>

<dl><dd><pre> Pmw.Color.setscheme(root,
     background = 'red3', foreground = 'white')</pre></dl>

<p>    This function does not modify the colors of already existing
    widgets.  Use <strong>Pmw.Color.changecolor()</strong> to do this.</p>

<p>    Note that <em>root</em> must be a Tk widget or toplevel.  To use the Tk
    option database of the root window or a Pmw megawidget, use the
    megawidget's <strong>hull</strong> component.  For example:</p>

<dl><dd><pre> root = megawidget.component('hull')
 Pmw.Color.setscheme(root, background = 'red3')</pre></dl>

<p></p>


</dt>
<dt> <strong>Pmw.Color.spectrum</strong>(<em>numColors</em>, <em>correction</em> = <strong>1.0</strong>, <em>saturation</em> = <strong>1.0</strong>, <em>intensity</em> = <strong>1.0</strong>, <em>extraOrange</em> = <strong>1</strong>, <em>returnHues</em> = <strong>0</strong>)<dd>
<p></p>
</dt>
</dl>
</dl>

    <center><P ALIGN="CENTER">
    <IMG SRC = blue_line.gif ALT = "" WIDTH=320 HEIGHT=5>
    </p></center>
    

    <font size=-1>
    <center><P ALIGN="CENTER">
    <a href="index.html">Home</a>. 
    Pmw 0.8.5
    Maintainer
    <a href="mailto:gregm@iname.com">gregm@iname.com</a>.
     9 Feb 2001
    
    </p></center>
    </font>

    </body>
    </html>