[gnome-devel-docs] tutorials python: commented samples and better pages for display widgets



commit 4dba3d75d1570969ffaee9b34e78076a1ecc666e
Author: Marta Maria Casetti <mmcasetti gmail com>
Date:   Thu Jun 14 16:20:21 2012 +0100

    tutorials python: commented samples and better pages for display widgets

 platform-demos/C/image.py.page          |   82 +++++++++++++++++++++++++++++-
 platform-demos/C/label.py.page          |   71 +++++++++++++++++++++++++-
 platform-demos/C/progressbar.py.page    |   37 ++++++++++----
 platform-demos/C/samples/image.py       |   25 +++++-----
 platform-demos/C/samples/label.py       |   16 +++---
 platform-demos/C/samples/progressbar.py |   26 ++++++----
 platform-demos/C/samples/spinner.py     |   23 ++++++---
 platform-demos/C/samples/statusbar.py   |   36 ++++++++------
 platform-demos/C/spinner.py.page        |   30 ++++++++---
 platform-demos/C/statusbar.py.page      |   39 +++++++++++---
 10 files changed, 297 insertions(+), 88 deletions(-)
---
diff --git a/platform-demos/C/image.py.page b/platform-demos/C/image.py.page
index 2de7315..43cef11 100644
--- a/platform-demos/C/image.py.page
+++ b/platform-demos/C/image.py.page
@@ -5,7 +5,7 @@
       id="image.py">
   <info>
     <link type="guide" xref="beginner.py#display-widgets"/>
-    <revision version="0.1" date="2012-05-05" status="stub"/>
+    <revision version="0.2" date="2012-06-14" status="draft"/>
 
     <credit type="author copyright">
       <name>Marta Maria Casetti</name>
@@ -19,9 +19,85 @@
   <title>Image</title>
   <media type="image" mime="image/png" src="media/image.png"/>
   <p>This GtkApplication displays an image file from the current directory.</p>
+
   <note><p>
-    If the image file isn't loaded successfully, the image will contain a "broken image" icon.  The <file>filename.png</file> needs to be in the current directory for this code to work.  Use your favorite picture!
+    If the image file is not loaded successfully, the image will contain a "broken image" icon.  The <file>filename.png</file> needs to be in the current directory for this code to work.
   </p></note>
-<code mime="text/x-python" style="numbered"><xi:include href="samples/image.py" parse="text"><xi:fallback/></xi:include></code>
 
+  <links type="section" />
+
+  <section id="code">
+  <title>Code used to generate this example</title>
+
+  <code mime="text/x-python" style="numbered"><xi:include href="samples/image.py" parse="text"><xi:fallback/></xi:include></code>
+
+  <p>Another way to obtain what we have in the example is to create the image as an instance of another class and add it to the instance of <code>MyWindow</code> in the <code>do_activate(self)</code> method:</p>
+      <code mime="text/x-python">
+# a class to create a window
+class MyWindow(Gtk.ApplicationWindow):
+    def __init__(self, app):
+        Gtk.Window.__init__(self, title="Welcome to GNOME", application=app)
+        self.set_default_size(300, 300)
+
+# a class to create an image
+class MyImage(Gtk.Image):
+    def __init__(self):
+        Gtk.Image.__init__(self)
+        self.set_from_file("gnome-image.png")
+
+class MyApplication(Gtk.Application):
+    def __init__(self):
+        Gtk.Application.__init__(self)
+
+    def do_activate(self):
+        # create an instance of MyWindow
+        win = MyWindow(self)
+        # create an instance of MyImage and add it to the window
+        win.add(MyImage())
+        # show the window and everything on it
+        win.show_all()</code>
+  </section>
+
+  <section id="methods">
+  <title>Useful methods for an Image widget</title>
+
+  <list>
+    <item><p>To set a stock icon as image, you can use <code>image.set_from_stock(stock_id, size)</code> where <code>stock_id</code> is a stock icon such as <code>Gtk.STOCK_ABOUT</code> (more can be found at <link href="http://developer.gnome.org/gtk3/3.4/gtk3-Stock-Items";>Stock Items</link>, with the caveat that they should be modified as above) and <code>size</code> is a stock icon size to be chosen from <code>Gtk.IconSize.INVALID, Gtk.IconSize.MENU, Gtk.IconSize.SMALL_TOOLBAR, Gtk.IconSize.LARGE_TOOLBAR, Gtk.IconSize.BUTTON, Gtk.IconSize.DND, Gtk.IconSize.DIALOG</code>.</p></item>
+    <item><p>You can also use <code>image.set_from_icon_name(icon_name, size)</code>, where <code>icon_name</code> is a stock icon name such as <code>"gtk-about"</code> (more can be found as above) and <code>size</code> is as above.</p></item>
+    <item><p>To load an image over a network use <code>image.set_from_pixbuf(pixbuf)</code>, where <code>pixbuf</code> is a <link href="http://developer.gnome.org/gdk-pixbuf/unstable//index.html";>GdkPixbuf</link>.</p>
+    <code mime="text/python">
+from gi.repository import Gtk
+from gi.repository import GdkPixbuf
+import sys
+
+class MyWindow(Gtk.ApplicationWindow):
+    # create a window
+    def __init__(self, app):
+        Gtk.Window.__init__(self, title="Welcome to GNOME", application=app)
+        self.set_default_size(300, 300)
+
+        # create a pixbuf from file filename="gnome-image.png", with width=32
+        # and height=64 amd boolean preserve_aspect_ratio=False.
+        pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale("gnome-image.png", 64, 128, False)
+
+        # create an image
+        image = Gtk.Image()
+        # set the content of the image as the pixbuf
+        image.set_from_pixbuf(pixbuf)
+        # add the image to the window
+        self.add(image)</code>
+    <p>If <code>preserve_aspect_ratio=True</code> we can use <code>new_from_file_at_size(filename, width, height)</code>. If <code>width</code> or <code>height</code> is <code>-1</code>, it is not constrained.</p>
+    <p> For loading from an input stream, see <code>new_from_stream()</code> and <code>new_from_stream_at_scale()</code> in the documentation</p>
+    </item>
+  </list>
+  </section>
+
+  <section id="references">
+  <title>References</title>
+  <p>In this sample we used the following:</p>
+  <list>
+    <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkImage.html";>GtkImage</link></p></item>
+    <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkWindow.html";>GtkWindow</link></p></item>
+  </list>
+  </section>
 </page>
diff --git a/platform-demos/C/label.py.page b/platform-demos/C/label.py.page
index ce8e465..8b2ea46 100644
--- a/platform-demos/C/label.py.page
+++ b/platform-demos/C/label.py.page
@@ -5,20 +5,85 @@
       id="label.py">
   <info>
     <link type="guide" xref="beginner.py#display-widgets"/>
-    <revision version="0.1" date="2012-04-28" status="review"/>
+    <revision version="0.2" date="2012-06-14" status="draft"/>
 
     <credit type="author copyright">
       <name>Marta Maria Casetti</name>
       <email>mmcasetti gmail com</email>
       <years>2012</years>
     </credit>
+    <credit type="author">
+      <name>Sebastian P&#246;lsterl</name>
+      <email>sebp k-d-w org</email>
+      <years>2012</years>
+    </credit>
 
-    <desc>A widget which displays text</desc>
+    <desc>A widget that displays a small to medium amount of text</desc>
   </info>
 
   <title>Label</title>
   <media type="image" mime="image/png" src="media/label.png"/>
   <p>A simple label</p>
 
-<code mime="text/x-vala" style="numbered"><xi:include href="samples/label.py" parse="text"><xi:fallback/></xi:include></code>
+  <links type="section" />
+
+  <section id="code">
+  <title>Code used to generate this example</title>
+
+  <code mime="text/x-python" style="numbered"><xi:include href="samples/label.py" parse="text"><xi:fallback/></xi:include></code>
+
+    <p>Another way to obtain what we have in the example is to create the label as an instance of another class and add it to the instance of <code>MyWindow</code> in the <code>do_activate(self)</code> method:</p>
+      <code mime="text/x-python">
+# a class to define a window
+class MyWindow(Gtk.ApplicationWindow):
+    def __init__(self, app):
+        Gtk.Window.__init__(self, title="Welcome to GNOME", application=app)
+        self.set_default_size(200, 100)
+
+# a class to define a label
+class MyLabel(Gtk.Label):
+    def __init__(self):
+        Gtk.Label.__init__(self)
+        self.set_text("Hello GNOME!")
+
+class MyApplication(Gtk.Application):
+    def __init__(self):
+        Gtk.Application.__init__(self)
+
+    def do_activate(self):
+        # create an instance of MyWindow
+        win = MyWindow(self)
+        # create an instance of MyLabel
+        label = MyLabel()
+        # and add it to the window
+        win.add(label)
+        # show the window and everything on it
+        win.show_all()</code>
+
+  </section>
+
+  <section id="methods">
+  <title>Useful methods for a Label widgets</title>
+  <list>
+    <item><p><code>label = Gtk.Label("Hello GNOME!")</code> could also be used create a label and set the text directly.</p></item>
+    <item><p><code>label.set_line_wrap(True)</code> breaks lines if the text of the label exceeds the size of the widget.</p></item>
+    <item><p><code>label.set_justify(Gtk.Justification.LEFT)</code> (or <code>Gtk.Justification.RIGHT, Gtk.Justification.CENTER, Gtk.Justification.FILL</code>) sets the alignment of the lines in the text of the label relative to each other. The method has no effect on a single-line label.</p></item>
+    <item><p>For decorated text we can use <code>label.set_markup("text")</code>, where <code>"text"</code> is a text in the <link href="http://developer.gnome.org/pango/stable/PangoMarkupFormat.html";>Pango Markup Language</link>. An example:</p>
+      <code mime="text/x-python"><![CDATA[
+label.set_markup("Text can be <small>small</small>, <big>big</big>, "
+                 "<b>bold</b>, <i>italic</i> and even point to somewhere "
+                 "in the <a href=\"http://www.gtk.org\"; "
+                 "title=\"Click to find out more\">internets</a>.")]]></code>
+    </item>
+  </list>
+  </section>
+
+  <section id="references">
+  <title>References</title>
+  <p>In this sample we used the following:</p>
+  <list>
+    <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkLabel.html";>GtkLabel</link></p></item>
+    <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkWindow.html";>GtkWindow</link></p></item>
+  </list>
+  </section>
 </page>
diff --git a/platform-demos/C/progressbar.py.page b/platform-demos/C/progressbar.py.page
index ceb557b..5b737c5 100644
--- a/platform-demos/C/progressbar.py.page
+++ b/platform-demos/C/progressbar.py.page
@@ -5,7 +5,7 @@
       id="progressbar.py">
   <info>
     <link type="guide" xref="beginner.py#display-widgets"/>
-    <revision version="0.1" date="2012-05-25" status="draft"/>
+    <revision version="0.2" date="2012-06-12" status="draft"/>
 
     <credit type="author copyright">
       <name>Marta Maria Casetti</name>
@@ -30,13 +30,30 @@
   </media>
   <p>This ProgressBar is stopped and started by pressing any key.</p>
 
-<code mime="text/x-python" style="numbered"><xi:include href="samples/progressbar.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/GtkProgressBar.html";>GtkProgressBar</link></p></item>
-  <item><p><link href="http://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html";>GLib - The Main Event Loop</link></p></item>
-  <item><p><link href="http://developer.gnome.org/gdk/stable/gdk-Keyboard-Handling";>Gdk - Key Values</link></p></item>
-</list>
+  <links type="section" />
+
+  <section id="code">
+  <title>Code used to generate this example</title>
+
+  <code mime="text/x-python" style="numbered"><xi:include href="samples/progressbar.py" parse="text"><xi:fallback/></xi:include></code>
+
+  </section>
+
+  <section id="methods">
+  <title>Useful methods for a ProgressBar widget</title>
+  <list>
+    <item><p>Instead of <code>progressbar.pulse()</code>, that makes the bar go back and forth, if we want the ProgressBar to "fill in" a fraction (a <code>float</code> between <code>0.0</code> and <code>1.0</code> included) of the bar that has been completed, use <code>progressbar.set_fraction(fraction)</code>.</p></item>
+    <item><p>To set a text and show it (superimposed over the bar) use <code>progressbar.set_text("some text")</code> and <code>progressbar.set_show_text(True)</code>. If a text is not set and <code>progressbar.set_show_text(True)</code> the text will be the percentage of the work that has been completed.</p></item>
+  </list>
+  </section>
+
+  <section id="references">
+  <title>References</title>
+  <p>In this sample we used the following:</p>
+  <list>
+    <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkProgressBar.html";>GtkProgressBar</link></p></item>
+    <item><p><link href="http://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html";>GLib - The Main Event Loop</link></p></item>
+    <item><p><link href="http://developer.gnome.org/gdk/stable/gdk-Keyboard-Handling";>Gdk - Key Values</link></p></item>
+  </list>
+  </section>
 </page>
diff --git a/platform-demos/C/samples/image.py b/platform-demos/C/samples/image.py
index 218ebdc..be5707e 100644
--- a/platform-demos/C/samples/image.py
+++ b/platform-demos/C/samples/image.py
@@ -1,26 +1,25 @@
-from gi.repository import GLib
 from gi.repository import Gtk
-from gi.repository import Gio
 import sys
 
 class MyWindow(Gtk.ApplicationWindow):
+    # create a window
     def __init__(self, app):
         Gtk.Window.__init__(self, title="Welcome to GNOME", application=app)
-        
-class MyImage(Gtk.Image):
-    def __init__(self):
-        Gtk.Image.__init__(self)
-        self.set_from_file("gnome-image.png")
-        
+        self.set_default_size(300, 300)
+
+        # create an image
+        image = Gtk.Image()
+        # set the content of the image as the file filename.png
+        image.set_from_file("gnome-image.png")
+        # add the image to the window
+        self.add(image)
+
 class MyApplication(Gtk.Application):
     def __init__(self):
-        Gtk.Application.__init__(self, application_id="org.gtk.example.grid")
-        
+        Gtk.Application.__init__(self)
+
     def do_activate(self):
         win = MyWindow(self)
-        win.set_default_size(300, 300)
-        win.set_position(Gtk.WindowPosition.CENTER)
-        win.add(MyImage())
         win.show_all()
 
     def do_startup(self):
diff --git a/platform-demos/C/samples/label.py b/platform-demos/C/samples/label.py
index 23811f8..ebca626 100644
--- a/platform-demos/C/samples/label.py
+++ b/platform-demos/C/samples/label.py
@@ -1,23 +1,25 @@
-from gi.repository import GLib
 from gi.repository import Gtk
-from gi.repository import Gio
 import sys
 
 class MyWindow(Gtk.ApplicationWindow):
+    # constructor for a Gtk.ApplicationWindow
     def __init__(self, app):
         Gtk.Window.__init__(self, title="Welcome to GNOME", application=app)
+        self.set_default_size(200, 100)
+
+        # create a label
         label = Gtk.Label()
+        # set the text of the label
         label.set_text("Hello GNOME!")
+        # add the label to the window
         self.add(label)
-        
+
 class MyApplication(Gtk.Application):
     def __init__(self):
-        Gtk.Application.__init__(self, application_id="org.gtk.example.grid")
-        
+        Gtk.Application.__init__(self)
+
     def do_activate(self):
         win = MyWindow(self)
-        win.set_default_size(200, 100)
-        win.set_position(Gtk.WindowPosition.CENTER)
         win.show_all()
 
     def do_startup(self):
diff --git a/platform-demos/C/samples/progressbar.py b/platform-demos/C/samples/progressbar.py
index 0476075..4641da9 100644
--- a/platform-demos/C/samples/progressbar.py
+++ b/platform-demos/C/samples/progressbar.py
@@ -3,25 +3,26 @@ from gi.repository import Gtk
 import sys
 
 class MyWindow(Gtk.ApplicationWindow):
+    # a window
     def __init__(self, app):
         Gtk.Window.__init__(self, title="ProgressBar Example", application=app)
         self.set_default_size(220, 20)
 
         # a progressbar
-        progress_bar = Gtk.ProgressBar()
-        self.add(progress_bar)
+        self.progress_bar = Gtk.ProgressBar()
+        # add the progressbar to the window
+        self.add(self.progress_bar)
 
-        self.bar = progress_bar
-
-        # the method pulse is called each 100 milliseconds
+        # the method self.pulse is called each 100 milliseconds
         # and self.source_id is set to be the ID of the event source
-        # (the bar moves)
+        # (i.e. the bar changes position every 100 milliseconds)
         self.source_id = GLib.timeout_add(100, self.pulse)
 
+    # event handler
     # any signal from the keyboard controls if the progressbar stops/starts
     def do_key_press_event(self, event):
-        # if the bar has been stopped (and source_id == 0 - see below),
-        # turn it back on
+        # if the progressbar has been stopped (therefore source_id == 0 - see
+        # "else" below), turn it back on
         if (self.source_id == 0):
             self.source_id = GLib.timeout_add(100, self.pulse)
         # if the bar is moving, remove the source with the ID of source_id
@@ -29,16 +30,19 @@ class MyWindow(Gtk.ApplicationWindow):
         else:
             GLib.source_remove(self.source_id)
             self.source_id = 0
+        # stop the signal emission
         return True
 
-    # the progressbar is in "activity mode"
+    # source function
+    # the progressbar is in "activity mode" when this method is called
     def pulse(self):
-        self.bar.pulse()
+        self.progress_bar.pulse()
+        # call the function again
         return True
 
 class MyApplication(Gtk.Application):
     def __init__(self):
-        Gtk.Application.__init__(self, application_id="org.example.spinner")
+        Gtk.Application.__init__(self)
 
     def do_activate(self):
         win = MyWindow(self)
diff --git a/platform-demos/C/samples/spinner.py b/platform-demos/C/samples/spinner.py
index 41980a3..517b657 100644
--- a/platform-demos/C/samples/spinner.py
+++ b/platform-demos/C/samples/spinner.py
@@ -1,35 +1,42 @@
-from gi.repository import GLib
 from gi.repository import Gtk
 from gi.repository import Gdk
 import sys
 
 class MyWindow(Gtk.ApplicationWindow):
+    # a window
     def __init__(self, app):
         Gtk.Window.__init__(self, title="Spinner Example", application=app)
         self.set_default_size(200, 200)
         self.set_border_width(30)
 
         # a spinner
-        spinner = Gtk.Spinner()
-        spinner.start()
-
-        self.spinner = spinner
-
-        self.add(spinner)
+        self.spinner = Gtk.Spinner()
+        # that by default spins
+        self.spinner.start()
+        # add the spinner to the window
+        self.add(self.spinner)
 
+    # event handler
     # a signal from the keyboard (space) controls if the spinner stops/starts
     def do_key_press_event(self, event):
+        # keyname is the symbolic name of the key value given by the event
         keyname = Gdk.keyval_name(event.keyval)
+        # if it is "space"
         if keyname == "space":
+            # and the spinner is active
             if self.spinner.get_property("active"):
+                # stop the spinner
                 self.spinner.stop()
+            # if the spinner is not active
             else:
+                # start it again
                 self.spinner.start()
+        # stop the signal emission
         return True
 
 class MyApplication(Gtk.Application):
     def __init__(self):
-        Gtk.Application.__init__(self, application_id="org.example.MyApplication")
+        Gtk.Application.__init__(self)
 
     def do_activate(self):
         win = MyWindow(self)
diff --git a/platform-demos/C/samples/statusbar.py b/platform-demos/C/samples/statusbar.py
index 529bbf2..bb1b622 100644
--- a/platform-demos/C/samples/statusbar.py
+++ b/platform-demos/C/samples/statusbar.py
@@ -3,6 +3,7 @@ from gi.repository import Gdk
 import sys
 
 class MyWindow(Gtk.ApplicationWindow):
+    # a window
     def __init__(self, app):
         Gtk.Window.__init__(self, title="StatusBar Example", application=app)
         self.set_default_size(200, 100)
@@ -15,40 +16,45 @@ class MyWindow(Gtk.ApplicationWindow):
         # connected to a callback
         button.connect("clicked", self.button_clicked_cb)
 
-        # the statusbar (the context_id is not shown in the UI but it is needed)
-        statusbar = Gtk.Statusbar()
-        context_id = statusbar.get_context_id("example")
-        # pushed a new message onto the statusbar's stack
-        statusbar.push(context_id, "Waiting for you to do something...")
+        # the statusbar
+        self.statusbar = Gtk.Statusbar()
+        # its context_id - not shown in the UI but needed to uniquely identify
+        # the source of a message
+        self.context_id = self.statusbar.get_context_id("example")
+        # we push a message onto the statusbar's stack
+        self.statusbar.push(self.context_id, "Waiting for you to do something...")
 
         # a grid to attach the widgets
         grid = Gtk.Grid()
         grid.set_column_spacing(5)
         grid.set_column_homogeneous(True)
         grid.set_row_homogeneous(True)
-        grid.attach(label, 1, 1, 1, 1)
+        grid.attach(label, 0, 0, 1, 1)
         grid.attach_next_to(button, label, Gtk.PositionType.RIGHT, 1, 1)
-        grid.attach(statusbar, 1, 2, 2, 1)
+        grid.attach(self.statusbar, 0, 1, 2, 1)
 
+        # add the grid to the window
         self.add(grid)
 
-        self.bar = statusbar
-        self.id = context_id
-
+    # callback function for the button clicked
     # if the button is clicked the event is signaled to the statusbar
     # onto which we push a new status
     def button_clicked_cb(self, button):
-        self.bar.push(self.id, "You clicked the button.")
+        self.statusbar.push(self.context_id, "You clicked the button.")
 
-    # any signal from the keyboard is signaled to the statusbar
-    # onto which we push a new status
+    # event handler
     def do_key_press_event(self, event):
-        self.bar.push(self.id, Gdk.keyval_name(event.keyval) + " key was pressed.")
+    # any signal from the keyboard is signaled to the statusbar
+    # onto which we push a new status with the symbolic name
+    # of the key pressed
+        self.statusbar.push(self.context_id, Gdk.keyval_name(event.keyval) +
+                                            " key was pressed.")
+        # stop the signal emission
         return True
 
 class MyApplication(Gtk.Application):
     def __init__(self):
-        Gtk.Application.__init__(self, application_id="org.example.spinner")
+        Gtk.Application.__init__(self)
 
     def do_activate(self):
         win = MyWindow(self)
diff --git a/platform-demos/C/spinner.py.page b/platform-demos/C/spinner.py.page
index abd5fff..af8091c 100644
--- a/platform-demos/C/spinner.py.page
+++ b/platform-demos/C/spinner.py.page
@@ -5,7 +5,7 @@
       id="spinner.py">
   <info>
     <link type="guide" xref="beginner.py#display-widgets"/>
-    <revision version="0.1" date="2012-05-24" status="draft"/>
+    <revision version="0.2" date="2012-06-12" status="draft"/>
 
     <credit type="author copyright">
       <name>Marta Maria Casetti</name>
@@ -20,12 +20,24 @@
   <media type="image" mime="image/png" src="media/spinner.png"/>
   <p>This Spinner is stopped and started by pressing the spacebar.</p>
 
-<code mime="text/x-python" style="numbered"><xi:include href="samples/spinner.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/GtkSpinner.html";>GtkSpinner</link></p></item>
-  <item><p><link href="http://developer.gnome.org/gdk/stable/gdk-Keyboard-Handling.html";>Key Values</link></p></item>
-</list>
+  <links type="section" />
+
+  <section id="code">
+  <title>Code used to generate this example</title>
+
+  <code mime="text/x-python" style="numbered"><xi:include href="samples/spinner.py" parse="text"><xi:fallback/></xi:include></code>
+
+  <note><p>
+    <code>Gdk.keyval_name(event.keyval)</code> converts the key value <code>event.keyval</code> into a symbolic name. The names and corresponding key values can be found <link href="http://git.gnome.org/browse/gtk+/tree/gdk/gdkkeysyms.h";>here</link>,but for instance <code>GDK_KEY_BackSpace</code> becomes the string <code>"BackSpace"</code>.
+  </p></note>
+  </section>
+
+  <section id="references">
+  <title>References</title>
+  <p>In this sample we used the following:</p>
+  <list>
+    <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkSpinner.html";>GtkSpinner</link></p></item>
+    <item><p><link href="http://developer.gnome.org/gdk/stable/gdk-Keyboard-Handling.html";>Key Values</link></p></item>
+  </list>
+  </section>
 </page>
diff --git a/platform-demos/C/statusbar.py.page b/platform-demos/C/statusbar.py.page
index 2623d4d..d0a1497 100644
--- a/platform-demos/C/statusbar.py.page
+++ b/platform-demos/C/statusbar.py.page
@@ -8,7 +8,7 @@
     <link type="seealso" xref="grid.py"/>
     <link type="seealso" xref="button.py"/>
     <link type="seealso" xref="label.py"/>
-    <revision version="0.1" date="2012-05-25" status="draft"/>
+    <revision version="0.2" date="2012-06-12" status="draft"/>
 
     <credit type="author copyright">
       <name>Marta Maria Casetti</name>
@@ -23,12 +23,33 @@
   <media type="image" mime="image/png" src="media/statusbar.png"/>
   <p>This statusbar tells you if you click the button or if you press any key (and which key).</p>
 
-<code mime="text/x-python" style="numbered"><xi:include href="samples/statusbar.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/GtkStatusbar.html";>GtkStatusbar</link></p></item>
-  <item><p><link href="http://developer.gnome.org/gdk/stable/gdk-Keyboard-Handling.html";>Gdk - Key Values</link></p></item>
-</list>
+  <links type="section" />
+
+  <section id="code">
+  <title>Code used to generate this example</title>
+
+  <code mime="text/x-python" style="numbered"><xi:include href="samples/statusbar.py" parse="text"><xi:fallback/></xi:include></code>
+
+  <note><p>
+    <code>Gdk.keyval_name(event.keyval)</code> converts the key value <code>event.keyval</code> into a symbolic name. The names and corresponding key values can be found <link href="http://git.gnome.org/browse/gtk+/tree/gdk/gdkkeysyms.h";>here</link>, but for instance <code>GDK_KEY_BackSpace</code> becomes the string <code>"BackSpace"</code>.
+  </p></note>
+  </section>
+
+  <section id="methods">
+  <title>Useful methods for a Statusbar widget</title>
+  <list>
+    <item><p><code>statusbar.pop(context_id)</code> removes the first message in the statusbar stack with the given <code>context_id</code>.</p></item>
+    <item><p><code>statusbar.remove_all(context_id)</code> removes all the messages in the statusbar stack with the given <code>context_id</code>.</p></item>
+    <item><p><code>statusbar.remove(context_id, message_id)</code> removes the message with the given <code>message_id</code> in the statusbar stack with the given <code>context_id</code>. The <code>message_id</code> is returned by <code>statusbar.push(context_id, "the message")</code> when pushing the message on the statusbar.</p></item>
+  </list>
+  </section>
+
+  <section id="references">
+  <title>References</title>
+  <p>In this sample we used the following:</p>
+  <list>
+    <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkStatusbar.html";>GtkStatusbar</link></p></item>
+    <item><p><link href="http://developer.gnome.org/gdk/stable/gdk-Keyboard-Handling.html";>Gdk - Key Values</link></p></item>
+  </list>
+  </section>
 </page>



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