Blob Blame History Raw
<?xml version='1.0' encoding='UTF-8'?>
<page xmlns="http://projectmallard.org/1.0/"
      xmlns:its="http://www.w3.org/2005/11/its"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      type="guide" style="task"
      id="colorbutton.py">
  <info>
    <title type="text">ColorButton (Python)</title>
    <link type="guide" xref="beginner.py#color-selectors"/>
    <link type="next" xref="fontchooserwidget.py"/>
    <revision version="0.1" date="2012-06-03" status="draft"/>

    <credit type="author copyright">
      <name>Marta Maria Casetti</name>
      <email its:translate="no">mmcasetti@gmail.com</email>
      <years>2012</years>
    </credit>

    <desc>A button to launch a color selection dialog</desc>
  </info>

  <title>ColorButton</title>
  <media type="image" mime="image/png" src="media/colorbutton.png"/>
  <p>This ColorButton launches a color selection dialog and prints in the terminal the RGB values of the color selected.</p>

  <links type="sections" />
  
  <section id="code">
  <title>Code used to generate this example</title>
  <code mime="text/x-python" style="numbered"><xi:include href="samples/colorbutton.py" parse="text"><xi:fallback/></xi:include></code>
  </section>

  <section id="methods">
  <title>Useful methods for a ColorButton widget</title>
  <p><code>set_color(color)</code>, where the <code>color</code> is defined as in the example, sets the color of the ColorButton, which by default is black. <code>get_color()</code> returns the color.</p>
    <p>In line 23 the <code>"color-set"</code> signal is connected to the callback function <code>on_color_chosen()</code> using <code><var>widget</var>.connect(<var>signal</var>, <var>callback function</var>)</code>. See <link xref="signals-callbacks.py"/> for a more detailed explanation.</p>
  </section>
  
  <section id="references">
  <title>API References</title>
  <p>In this sample we used the following:</p>
  <list>
    <item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkColorButton.html">GtkColorButton</link></p></item>
    <item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkColorChooser.html">GtkColorChooser</link></p></item>
    <item><p><link href="http://developer.gnome.org/gdk3/stable/gdk3-RGBA-Colors.html">RGBA Colors</link></p></item>
  </list>
  </section>
</page>