[gnome-devel-docs/beginners: 11/12] GTK+ Python tutorial: ScrolledWindow



commit 39cc0557abc30e8ba8aeefbf3fdce6c119c840f0
Author: Marta Maria Casetti <mmcasetti gmail com>
Date:   Thu Mar 7 11:26:34 2013 +0000

    GTK+ Python tutorial: ScrolledWindow
    
    Done?

 beginners-docs/C/samples/scrolledwindow.py |    8 ---
 beginners-docs/C/scrolledwindow.py.page    |   72 +++++++++++++++++++--------
 2 files changed, 50 insertions(+), 30 deletions(-)
---
diff --git a/beginners-docs/C/samples/scrolledwindow.py b/beginners-docs/C/samples/scrolledwindow.py
index 05137b7..b2fe83e 100644
--- a/beginners-docs/C/samples/scrolledwindow.py
+++ b/beginners-docs/C/samples/scrolledwindow.py
@@ -6,20 +6,15 @@ class MyWindow(Gtk.ApplicationWindow):
         Gtk.Window.__init__(self, title="ScrolledWindow Example", application=app)
         self.set_default_size(200, 200)
 
-        # the scrolledwindow
         scrolled_window = Gtk.ScrolledWindow()
         scrolled_window.set_border_width(10)
-        # there is always the scrollbar (otherwise: AUTOMATIC - only if needed - or NEVER)
         scrolled_window.set_policy(Gtk.PolicyType.ALWAYS, Gtk.PolicyType.ALWAYS)
 
-        # an image - slightly larger than the window...
         image = Gtk.Image()
         image.set_from_file("gnome-image.png")
 
-        # add the image to the scrolledwindow
         scrolled_window.add_with_viewport(image)
 
-        # add the scrolledwindow to the window
         self.add(scrolled_window)
 
 class MyApplication(Gtk.Application):
@@ -30,9 +25,6 @@ class MyApplication(Gtk.Application):
         win = MyWindow(self)
         win.show_all()
 
-    def do_startup(self):
-        Gtk.Application.do_startup(self)
-
 app = MyApplication()
 exit_status = app.run(sys.argv)
 sys.exit(exit_status)
diff --git a/beginners-docs/C/scrolledwindow.py.page b/beginners-docs/C/scrolledwindow.py.page
index 68b8b92..8aed869 100644
--- a/beginners-docs/C/scrolledwindow.py.page
+++ b/beginners-docs/C/scrolledwindow.py.page
@@ -5,9 +5,8 @@
       id="scrolledwindow.py">
   <info>
     <title type="text">ScrolledWindow (Python)</title>
-    <link type="guide" xref="beginner.py#scrolling"/>
     <link type="next" xref="paned.py"/>
-    <revision version="0.1" date="2012-05-26" status="draft"/>
+    <revision version="0.2" date="2013-03-07" status="draft"/>
 
     <credit type="author copyright">
       <name>Marta Maria Casetti</name>
@@ -19,31 +18,60 @@
   </info>
 
   <title>ScrolledWindow</title>
+  
+  <synopsis><p>Sometime you want a smaller window for a bigger child widget. The 
+  solution is the ScrolledWindow, a simple way to add scrollbars.</p></synopsis>
+  
+  <links type="section" />
+    
+  <section id="example">
+  <title>An example</title>
+
+  <p>A simple example: a window to which we add a ScrolledWindow widget to be 
+  able to see a bigger image, which is the child of the ScrolledWindow.</p>    
+
+  <code mime="text/x-python" style="numbered"><xi:include href="samples/scrolledwindow.py" 
parse="text"><xi:fallback/></xi:include></code>
+
+  <p>If you run the code above, you should get something like the image below.</p>
+
   <media type="image" mime="image/png" src="media/scrolledwindow.png"/>
-  <p>An image in a scrolled window.</p>
+  </section>
 
-  <links type="section" />
+  <section id="in-depth">
+  <title>A more in-depth look</title>
+  
+  <p>As with the <link xref="grid.py"/>, we add the child widget to the 
+  ScrolledWindow (line 16) and then the ScrolledWindow to the window (line 18).</p>
+  
+  <p>The method <code>set_policy(<var>hscrollbar_policy</var>, <var>vscrollbar_policy</var>)</code> 
+  in line 11 describes when the horizontal and vertical scrollbars of the window 
+  appear. The options are: <code>Gtk.Policy.AUTOMATIC</code> (the scrollbar 
+  appears when needed), <code>Gtk.Policy.ALWAYS</code>, 
+  <code>Gtk.Policy.NEVER</code> (self-explanatory).</p>
+
+  <p>The method <code>set_placement(<var>window_placement</var>)</code> sets the 
+  placement of the contents with respect to the scrollbars for the scrolled 
+  window. The options for the argument are <code>Gtk.CornerType.TOP_LEFT</code> 
+  (default: the scrollbars are on the bottom and on the right of the window), 
+  <code>Gtk.CornerType.TOP_RIGHT</code>, <code>Gtk.CornerType.BOTTOM_LEFT</code>, 
+  <code>Gtk.CornerType.BOTTOM_RIGHT</code>.</p>  
 
-  <section id="code">
-    <title>Code used to generate this example</title>
-    <code mime="text/x-python" style="numbered"><xi:include href="samples/scrolledwindow.py" 
parse="text"><xi:fallback/></xi:include></code>
   </section>
-  <section id="methods">
-    <title>Useful methods for a ScrolledWindow widget</title>
-    <list>
-      <item><p><code>set_policy(hscrollbar_policy, vscrollbar_policy)</code> where each of the arguments is 
one of <code>Gtk.Policy.AUTOMATIC, Gtk.Policy.ALWAYS, Gtk.Policy.NEVER</code> regulates whether the 
horizontal and vertical scrollbars should appear: with <code>AUTOMATIC</code> they appear only if needed, 
<code>ALWAYS</code> and <code>NEVER</code> are self-explanatory.</p></item>
-      <item><p><code>add_with_viewport(widget)</code> is used to add the Gtk.Widget <code>widget</code> 
without native scrolling capabilities inside the window.</p></item>
-      <item><p><code>set_placement(window_placement)</code> sets the placement of the contents with respect 
to the scrollbars for the scrolled window. The options for the argument are 
<code>Gtk.CornerType.TOP_LEFT</code> (default: the scrollbars are on the bottom and on the right of the 
window), <code>Gtk.CornerType.TOP_RIGHT, Gtk.CornerType.BOTTOM_LEFT, 
Gtk.CornerType.BOTTOM_RIGHT</code>.</p></item>
-      <item><p><code>set_hadjustment(adjustment)</code> and <code>set_vadjustment(adjustment)</code> set the 
Gtk.Adjustment <code>adjustment</code>. This is the representation of a value with a lower and upper bound, 
together with step and page increments, and a page size, and it is constructed as <code>Gtk.Adjustment(value, 
lower, upper, step_increment, page_increment, page_size)</code> where the fields are of type 
<code>float</code>. (Note that <code>step_increment</code> is not used in this case, it can be set to 
<code>0</code>.)</p></item>
-    </list>
+  
+  <section id="exercises">
+  <title>Exercises</title>
+  
+  <p>How do you add two images inside a ScrolledWindow?</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/GtkScrolledWindow.html";>GtkScrolledWindow</link></p></item>
-      <item><p><link 
href="http://developer.gnome.org/gtk3/unstable/gtk3-Standard-Enumerations.html";>Standard 
Enumerations</link></p></item>
-      <item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkImage.html";>GtkImage</link></p></item>
-    </list>
+  <title>API References</title>
+  <p>In this sample we used the following:</p>
+  <list>
+    <item><p><link 
href="http://developer.gnome.org/gtk3/unstable/GtkScrolledWindow.html";>GtkScrolledWindow</link></p></item>
+    <item><p><link href="http://developer.gnome.org/gtk3/unstable/gtk3-Standard-Enumerations.html";>Standard 
Enumerations</link></p></item>
+    <item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkImage.html";>GtkImage</link></p></item>
+  </list>
   </section>
 </page>


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