[gnome-devel-docs] tutorials python: colorbutton updated



commit 1431917d090e642e542613463531b28ad2d6320d
Author: Marta Maria Casetti <mmcasetti gmail com>
Date:   Mon Aug 6 14:18:25 2012 +0100

    tutorials python: colorbutton updated

 platform-demos/C/colorbutton.py.page    |   30 +++++++++++++++++++++---------
 platform-demos/C/samples/colorbutton.py |   16 +++++++---------
 2 files changed, 28 insertions(+), 18 deletions(-)
---
diff --git a/platform-demos/C/colorbutton.py.page b/platform-demos/C/colorbutton.py.page
index 7ba0fac..13dfb4a 100644
--- a/platform-demos/C/colorbutton.py.page
+++ b/platform-demos/C/colorbutton.py.page
@@ -20,13 +20,25 @@
   <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>
 
-<code mime="text/x-python" style="numbered"><xi:include href="samples/colorbutton.py" parse="text"><xi:fallback/></xi:include></code>
-<p>
-  In this sample we used the following:
-</p>
-<list>
-  <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkColorButton.html";>GtkColorButton</link></p></item>
-  <item><p><link href="http://developer.gnome.org/gtk3/3.4/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>
+  <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)</color>, 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>
+  </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>
diff --git a/platform-demos/C/samples/colorbutton.py b/platform-demos/C/samples/colorbutton.py
index 503f4e1..ff5121e 100644
--- a/platform-demos/C/samples/colorbutton.py
+++ b/platform-demos/C/samples/colorbutton.py
@@ -10,19 +10,17 @@ class MyWindow(Gtk.ApplicationWindow):
 
         # a colorbutton (which opens a dialogue window in
         # which we choose a color)
-        button = Gtk.ColorButton()
+        self.button = Gtk.ColorButton()
         # with a default color (blue, in this instance)
-        # if not chosen it will be black
         color = Gdk.RGBA()
         color.red = 0.0
         color.green = 0.0
         color.blue = 1.0
         color.alpha = 0.5
-        button.set_rgba(color)
+        self.button.set_rgba(color)
 
         # choosing a color in the dialogue window emits a signal
-        button.connect("color-set", self.on_color_chosen)
-        self.button = button
+        self.button.connect("color-set", self.on_color_chosen)
 
         # a label
         label = Gtk.Label()
@@ -30,17 +28,17 @@ class MyWindow(Gtk.ApplicationWindow):
 
         # a grid to attach button and label
         grid = Gtk.Grid()
-        grid.attach(button, 1, 1, 2, 1)
-        grid.attach(label, 1, 2, 2, 1)
+        grid.attach(self.button, 0, 0, 2, 1)
+        grid.attach(label, 0, 1, 2, 1)
         self.add(grid)
 
     # if a new color is chosen, we print it as rgb(r,g,b) in the terminal
     def on_color_chosen(self, user_data):
-        print "You chose another color: " + self.button.get_rgba().to_string()
+        print "You chose the color: " + self.button.get_rgba().to_string()
 
 class MyApplication(Gtk.Application):
     def __init__(self):
-        Gtk.Application.__init__(self, application_id="org.example.colorbutton")
+        Gtk.Application.__init__(self)
 
     def do_activate(self):
         win = MyWindow(self)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]