[gnome-devel-docs] tutorials python: paned example and page



commit ed645f56554a09e75558edd05064f666a4b19133
Author: Marta Maria Casetti <mmcasetti gmail com>
Date:   Wed Aug 15 12:04:12 2012 +0100

    tutorials python: paned example and page

 platform-demos/C/media/paned.png  |  Bin 0 -> 63597 bytes
 platform-demos/C/paned.py.page    |   44 +++++++++++++++++++++++++++++++++++++
 platform-demos/C/samples/paned.py |   40 +++++++++++++++++++++++++++++++++
 platform-demos/C/samples/tux.png  |  Bin 0 -> 21644 bytes
 platform-demos/Makefile.am        |    4 +++
 5 files changed, 88 insertions(+), 0 deletions(-)
---
diff --git a/platform-demos/C/media/paned.png b/platform-demos/C/media/paned.png
new file mode 100644
index 0000000..642de83
Binary files /dev/null and b/platform-demos/C/media/paned.png differ
diff --git a/platform-demos/C/paned.py.page b/platform-demos/C/paned.py.page
new file mode 100644
index 0000000..a0e6b57
--- /dev/null
+++ b/platform-demos/C/paned.py.page
@@ -0,0 +1,44 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<page xmlns="http://projectmallard.org/1.0/";
+      xmlns:xi="http://www.w3.org/2001/XInclude";
+      type="guide" style="task"
+      id="paned.py">
+  <info>
+    <link type="guide" xref="beginner.py#layout"/>
+    <revision version="0.1" date="2012-08-15" status="draft"/>
+
+    <credit type="author copyright">
+      <name>Marta Maria Casetti</name>
+      <email>mmcasetti gmail com</email>
+      <years>2012</years>
+    </credit>
+
+    <desc>A widget with two adjustable panes</desc>
+  </info>
+
+  <title>Paned</title>
+  <media type="image" mime="image/png" src="media/paned.png"/>
+  <p>Two images in two adjustable panes, horizontally aligned.</p>
+
+  <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/paned.py" parse="text"><xi:fallback/></xi:include></code>
+  </section>
+
+  <section id="methods">
+    <title>Useful methods for a Paned widget</title>
+    <p>To have two vertically aligned panes, use <code>Gtk.Orientation.VERTICAL</code> instead of <code>Gtk.Orientation.HORIZONTAL</code>. The method <code>add1(widget1)</code> will add the <code>widget1</code> to the top pane, and <code>add2(widget2)</code> will add the <code>widget2</code> to the bottom pane.</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/stable/GtkPaned.html";>GtkPaned</link></p></item>
+      <item><p><link href="http://developer.gnome.org/gtk3/stable/gtk3-Standard-Enumerations.html#GtkOrientation";>Standard Enumerations</link></p></item>
+      <item><p><link href="http://developer.gnome.org/gtk3/unstable/GtkImage.html";>GtkImage</link></p></item>
+    </list>
+  </section>
+</page>
diff --git a/platform-demos/C/samples/paned.py b/platform-demos/C/samples/paned.py
new file mode 100644
index 0000000..0d6ab34
--- /dev/null
+++ b/platform-demos/C/samples/paned.py
@@ -0,0 +1,40 @@
+from gi.repository import Gtk
+import sys
+
+class MyWindow(Gtk.ApplicationWindow):
+    def __init__(self, app):
+        Gtk.Window.__init__(self, title="Paned Example", application=app)
+        self.set_default_size(450, 350)
+
+        # a new widget with two adjustable panes,
+        # one on the left and one on the right
+        paned = Gtk.Paned.new(Gtk.Orientation.HORIZONTAL)
+
+        # two images
+        image1 = Gtk.Image()
+        image1.set_from_file("gnome-image.png")
+        image2 = Gtk.Image()
+        image2.set_from_file("tux.png")
+
+        # add the first image to the left pane
+        paned.add1(image1)
+        # add the second image to the right pane
+        paned.add2(image2)
+
+        # add the panes to the window
+        self.add(paned)
+
+class MyApplication(Gtk.Application):
+    def __init__(self):
+        Gtk.Application.__init__(self)
+
+    def do_activate(self):
+        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/platform-demos/C/samples/tux.png b/platform-demos/C/samples/tux.png
new file mode 100644
index 0000000..abb9c2b
Binary files /dev/null and b/platform-demos/C/samples/tux.png differ
diff --git a/platform-demos/Makefile.am b/platform-demos/Makefile.am
index e92ba0b..7fa265f 100644
--- a/platform-demos/Makefile.am
+++ b/platform-demos/Makefile.am
@@ -107,6 +107,7 @@ demo_sources = \
 	samples/messagedialog.py		\
 	samples/messagedialog.vala		\
 	samples/muteswan.png			\
+	samples/paned.py				\
 	samples/progressbar.c			\
 	samples/progressbar.js			\
 	samples/progressbar.py			\
@@ -159,6 +160,7 @@ demo_sources = \
 	samples/treeview_simple_liststore.py	\
 	samples/treeview_simple_liststore.vala	\
 	samples/treeview_treestore.py	\
+	samples/tux.png			\
 	samples/window.c			\
 	samples/window.js			\
 	samples/window.py			\
@@ -221,6 +223,7 @@ DOC_FIGURES = \
 	media/message-board.ogv			\
 	media/messagedialog.png			\
 	media/opensuse.png			\
+	media/paned.png					\
 	media/photo-wall.png			\
 	media/photo-wall-focused.png		\
 	media/progressbar.ogv			\
@@ -348,6 +351,7 @@ DOC_PAGES =				\
 	messagedialog.py.page		\
 	messagedialog.vala.page		\
 	model-view-controller.py.page		\
+	paned.py.page		\
 	photo-wall.c.page		\
 	progressbar.c.page		\
 	progressbar.js.page		\



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