summaryrefslogtreecommitdiff
path: root/docs/reference/pygtk-gtkcolorbutton.xml
blob: e5c81b88c0cad99bfafd8904ecee89d8477da567 (plain)
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
<?xml version="1.0" standalone="no"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
    "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">

<refentry id="class-gtkcolorbutton">
  <refnamediv>
    <refname>gtk.ColorButton</refname> <refpurpose>a button to launch a
    color selection dialog (new in PyGTK 2.4)</refpurpose>
  </refnamediv>

  <refsect1>
    <title>Synopsis</title>

    <classsynopsis language="python">
      <ooclass><classname>gtk.ColorButton</classname></ooclass>
      <ooclass><classname><link linkend="class-gtkbutton">gtk.Button</link></classname></ooclass>
      <constructorsynopsis language="python">
	<methodname><link linkend="constructor-gtkcolorbutton">gtk.ColorButton</link></methodname>
	<methodparam><parameter role="keyword">color</parameter><initializer>gtk.gdk.Color(0,0,0)</initializer></methodparam>
      </constructorsynopsis>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gtkcolorbutton--set-color">set_color</link></methodname>
	<methodparam><parameter role="keyword">color</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gtkcolorbutton--get-color">get_color</link></methodname>
	<methodparam></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gtkcolorbutton--set-alpha">set_alpha</link></methodname>
	<methodparam><parameter role="keyword">alpha</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gtkcolorbutton--get-alpha">get_alpha</link></methodname>
	<methodparam></methodparam>  </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gtkcolorbutton--set-use-alpha">set_use_alpha</link></methodname>
	<methodparam><parameter role="keyword">use_alpha</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gtkcolorbutton--get-use-alpha">get_use_alpha</link></methodname>
	<methodparam></methodparam>  </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gtkcolorbutton--set-title">set_title</link></methodname>
	<methodparam><parameter role="keyword">title</parameter></methodparam>
      </methodsynopsis>
      <methodsynopsis language="python">
	<methodname><link linkend="method-gtkcolorbutton--get-title">get_title</link></methodname>
	<methodparam></methodparam>  </methodsynopsis>
    </classsynopsis>

  </refsect1>

  <refsect1>
    <title>Ancestry</title>

<synopsis>+-- <link linkend="class-gobject">gobject.GObject</link>
  +-- <link linkend="class-gtkobject">gtk.Object</link>
    +-- <link linkend="class-gtkwidget">gtk.Widget</link>
      +-- <link linkend="class-gtkcontainer">gtk.Container</link>
        +-- <link linkend="class-gtkbin">gtk.Bin</link>
          +-- <link linkend="class-gtkbutton">gtk.Button</link>
            +-- <link linkend="class-gtkcolorbutton">gtk.ColorButton</link>
</synopsis>

  </refsect1>
  
  <refsect1>
		<title>Implemented Interfaces</title>
		<para>
			<link linkend="class-gtkcolorbutton"><classname>gtk.ColorButton</classname></link>
			implements 
			<link linkend="class-gtkbuildable"><classname>gtk.Buildable</classname></link>
		</para>
	</refsect1>


  <refsect1 id="properties-gtkcolorbutton">
    <title>gtk.ColorButton Properties</title>

    <para><link linkend="properties-gtkobject">gtk.Object Properties</link></para>
    <para><link linkend="properties-gtkwidget">gtk.Widget Properties</link></para>
    <para><link linkend="properties-gtkcontainer">gtk.Container Properties</link></para>
    <para><link linkend="properties-gtkbutton">gtk.Button Properties</link></para>

    <blockquote role="properties">
      <informaltable pgwide="1" frame="none">
	<tgroup cols="3">
	  <colspec column="1" colwidth="1in"/>
	  <colspec column="2" colwidth="1in"/>
	  <colspec column="3" colwidth="4in"/>
	  <tbody>

	    <row valign="top">
	      <entry>"alpha"</entry>
	      <entry>Read-Write</entry>
	      <entry>The selected opacity value (0 fully transparent, 65535
fully opaque). Available in GTK+ 2.4 and above.</entry>
	    </row>

	    <row valign="top">
	      <entry>"color"</entry>
	      <entry>Read-Write</entry>
	      <entry>The selected color. Available in GTK+ 2.4 and above.</entry>
	    </row>

	    <row valign="top">
	      <entry>"title"</entry>
	      <entry>Read-Write</entry>
	      <entry>The title of the color selection dialog. Available in
	      GTK+ 2.4 and above.</entry>
	    </row>

	    <row valign="top">
	      <entry>"use-alpha"</entry>
	      <entry>Read-Write</entry>
	      <entry>If <literal>True</literal>, the color swatch on the
	      button is rendered against a checkerboard background to show
	      its opacity and the opacity slider is displayed in the color
	      selection dialog. Available in GTK+ 2.4 and above.</entry>
	    </row>

	  </tbody>
	</tgroup>
      </informaltable>
    </blockquote>

  </refsect1>

  <refsect1 id="style-properties-gtkcolorbutton">
    <title>gtk.ColorButton Style Properties</title>

    <para><link linkend="style-properties-gtkwidget">gtk.Widget Style Properties</link></para>
    <para><link linkend="style-properties-gtkbutton">gtk.Button Style Properties</link></para>

  </refsect1>

  <refsect1 id="signal-prototypes-gtkcolorbutton">
    <title>gtk.ColorButton Signal Prototypes</title>

    <para><link linkend="signal-prototypes-gobject">gobject.GObject Signal Prototypes</link></para>
    <para><link linkend="signal-prototypes-gtkobject">gtk.Object Signal Prototypes</link></para>
    <para><link linkend="signal-prototypes-gtkwidget">gtk.Widget Signal Prototypes</link></para>
    <para><link linkend="signal-prototypes-gtkcontainer">gtk.Container Signal Prototypes</link></para>
    <para><link linkend="signal-prototypes-gtkbutton">gtk.Button Signal Prototypes</link></para>

    <variablelist>
      <varlistentry>
        <term>"<link linkend="signal-gtkcolorbutton--color-set">color-set</link>"</term>
        <listitem>
          <methodsynopsis language="python"><methodname>callback</methodname>
            <methodparam><parameter>colorbutton</parameter></methodparam>
            <methodparam><parameter>user_param1</parameter></methodparam>
            <methodparam><parameter>...</parameter></methodparam>
          </methodsynopsis>
        </listitem>
      </varlistentry>
    </variablelist>

  </refsect1>

  <refsect1>
    <title>Description</title>

    <para>The <link
    linkend="class-gtkcolorbutton"><classname>gtk.ColorButton</classname></link>
    is a button that displays the currently selected color and, when
    clicked, opens a <link
    linkend="class-gtkcolorselectiondialog"><classname>gtk.ColorSelectionDialog</classname></link>
    to change the color. It's a suitable widget for selecting a color in a
    preference dialog. The <link
    linkend="class-gtkcolorbutton"><classname>gtk.ColorButton</classname></link>
    is available in PyGTK 2.4 and above.</para>

 </refsect1>

  <refsect1 id="constructor-gtkcolorbutton">
    <title>Constructor</title>

    <programlisting><constructorsynopsis language="python">
	<methodname>gtk.ColorButton</methodname>
	<methodparam><parameter
		       role="keyword">color</parameter><initializer>gtk.gdk.Color(0,0,0)</initializer></methodparam>
      </constructorsynopsis></programlisting>
    <variablelist>
      <varlistentry>
	<term><parameter role="keyword">color</parameter>&nbsp;:</term>
	<listitem><simpara>an optional <link linkend="class-gdkcolor"><classname>gtk.gdk.Color</classname></link> to set the current color with</simpara></listitem>
      </varlistentry>
      <varlistentry>
	<term><emphasis>Returns</emphasis>&nbsp;:</term>
	<listitem><simpara>a new color button.</simpara></listitem>
      </varlistentry>
    </variablelist>

    <note>
      <para>This constructor is available in PyGTK 2.4 and above.</para>
    </note>
    
    <para>Creates a new color button with the current color set to the color
specified by the optional <link
linkend="class-gdkcolor"><classname>gtk.gdk.Color</classname></link>
<parameter>color</parameter>. A color button is a small button containing a
swatch representing the current selected color. When the button is clicked,
a <link
linkend="class-gtkcolorselectiondialog"><classname>gtk.ColorSelectionDialog</classname></link>
will open, allowing the user to select a color. The swatch will be updated
to reflect the new color the user selects.</para>

  </refsect1>

  <refsect1>
    <title>Methods</title>

    <refsect2 id="method-gtkcolorbutton--set-color">
      <title>gtk.ColorButton.set_color</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>set_color</methodname>
	  <methodparam><parameter role="keyword">color</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">color</parameter>&nbsp;:</term>
	  <listitem><simpara>A <link linkend="class-gdkcolor"><classname>gtk.gdk.Color</classname></link> to set the current color with.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This method is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <methodname>set_color</methodname>() method sets the current
      color (and the "color" property) to the color specified by the <link
      linkend="class-gdkcolor"><classname>gtk.gdk.Color</classname></link>
      <parameter>color</parameter>.</para>

    </refsect2>

    <refsect2 id="method-gtkcolorbutton--get-color">
      <title>gtk.ColorButton.get_color</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_color</methodname>
	  <methodparam></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>a <link
	  linkend="class-gdkcolor"><classname>gtk.gdk.Color</classname></link>
	  specifying the current color.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This method is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <methodname>get_color</methodname>() method returns the
      value of the "color" property which is a <link
      linkend="class-gdkcolor"><classname>gtk.gdk.Color</classname></link>
      specifying the current color in the <link
      linkend="class-gtkcolorbutton"><classname>gtk.ColorButton</classname></link>
      widget.</para>

    </refsect2>

    <refsect2 id="method-gtkcolorbutton--set-alpha">
      <title>gtk.ColorButton.set_alpha</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>set_alpha</methodname>
	  <methodparam><parameter role="keyword">alpha</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">alpha</parameter>&nbsp;:</term>
	  <listitem><simpara>The opacity in the range 0 to
	  65535.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This method is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <methodname>set_alpha</methodname>() method sets the current
      opacity (and the "alpha" property) to the value specified by
      <parameter>alpha</parameter>.</para>

    </refsect2>

    <refsect2 id="method-gtkcolorbutton--get-alpha">
      <title>gtk.ColorButton.get_alpha</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_alpha</methodname>
	  <methodparam></methodparam>  </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara>the opacity in the range 0 to
	  65535.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This method is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <methodname>get_alpha</methodname>() method returns the
      value of the "alpha" property that contains the opacity setting.</para>

    </refsect2>

    <refsect2 id="method-gtkcolorbutton--set-use-alpha">
      <title>gtk.ColorButton.set_use_alpha</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>set_use_alpha</methodname>
	  <methodparam><parameter role="keyword">use_alpha</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">use_alpha</parameter>&nbsp;:</term>
	  <listitem><simpara>if <literal>True</literal>, the color button
	  should use the alpha channel.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This method is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <methodname>set_use_alpha</methodname>() method sets the
      "use-alpha" property to the value of
      <parameter>use_alpha</parameter>. If <parameter>use_alpha</parameter>
      is <literal>True</literal>, the color swatch on the button is rendered
      against a checkerboard background to show its opacity and the opacity
      slider is displayed in the color selection dialog.</para>

    </refsect2>

    <refsect2 id="method-gtkcolorbutton--get-use-alpha">
      <title>gtk.ColorButton.get_use_alpha</title>

      <programlisting><methodsynopsis language="python">
    <methodname>get_use_alpha</methodname>
	  <methodparam></methodparam>  </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
	  <listitem><simpara><literal>True</literal> if the color sample
	  should use the alpha channel</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This method is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <methodname>get_use_alpha</methodname>() method returns the
      value of the "use-alpha" property. If <literal>True</literal> the
      color selection dialog should use the alpha channel.</para>

    </refsect2>

    <refsect2 id="method-gtkcolorbutton--set-title">
      <title>gtk.ColorButton.set_title</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>set_title</methodname>
	  <methodparam><parameter role="keyword">title</parameter></methodparam>
	</methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><parameter role="keyword">title</parameter>&nbsp;:</term>
	  <listitem><simpara>a string containing the new <link
	  linkend="class-gtkcolorselectiondialog"><classname>gtk.ColorSelectionDialog</classname></link>
	  title.</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This method is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <methodname>set_title</methodname>() method sets the title
      for the color selection dialog to the string contained in
      <parameter>title</parameter>. The "title" property is also set. </para>

    </refsect2>

    <refsect2 id="method-gtkcolorbutton--get-title">
      <title>gtk.ColorButton.get_title</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>get_title</methodname>
	  <methodparam></methodparam>  </methodsynopsis></programlisting>
      <variablelist>
	<varlistentry>
	  <term><emphasis>Returns</emphasis>&nbsp;:</term>
      <listitem><simpara>the title of the <link
      linkend="class-gtkcolorselectiondialog"><classname>gtk.ColorSelectionDialog</classname></link></simpara></listitem>
    </varlistentry>
  </variablelist>

      <note>
	<para>This method is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The <methodname>get_title</methodname>() method returns the
      value of the "title" property that contains the title of the color
      selection dialog.</para>

    </refsect2>

  </refsect1>

  <refsect1>
    <title>Signals</title>

    <refsect2 id="signal-gtkcolorbutton--color-set">
      <title>The "color-set" gtk.ColorButton Signal</title>

      <programlisting><methodsynopsis language="python">
	  <methodname>callback</methodname>
	  <methodparam><parameter>colorbutton</parameter></methodparam>
	  <methodparam><parameter>user_param1</parameter></methodparam>
	  <methodparam><parameter>...</parameter></methodparam>
	</methodsynopsis></programlisting>

      <variablelist>
	<varlistentry>
	  <term><parameter>colorbutton</parameter>&nbsp;:</term>
	  <listitem><simpara>the colorbutton that received the
signal</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>user_param1</parameter>&nbsp;:</term>
          <listitem><simpara>the first user parameter (if any) specified
with the <link
linkend="method-gobject--connect"><methodname>connect</methodname>()</link>
method</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><parameter>...</parameter>&nbsp;:</term>
	  <listitem><simpara>additional user parameters (if
any)</simpara></listitem>
	</varlistentry>
      </variablelist>

      <note>
	<para>This signal is available in PyGTK 2.4 and above.</para>
      </note>

      <para>The "color-set" signal is emitted when the user selects a
      color. When handling this signal, use the <link
      linkend="method-gtkcolorbutton--get-color"><methodname>get_color</methodname>()</link>
      and the <link
      linkend="method-gtkcolorbutton--get-alpha"><methodname>get_alpha</methodname>()</link>
      methods to find out what color was just selected.</para>

    </refsect2>

  </refsect1>

</refentry>