[gnome-devel-docs] tutorials python: example of a spinner



commit 8e3cef0e28d92d5d58996d4da610d4a9088f4436
Author: Marta Maria Casetti <mmcasetti gmail com>
Date:   Thu May 24 18:44:29 2012 +0100

    tutorials python: example of a spinner

 platform-demos/C/samples/spinner.py |   43 +++++++++++++++++++++++++++++++++++
 platform-demos/C/spinner.py.page    |   30 ++++++++++++++++++++++++
 platform-demos/Makefile.am          |    4 ++-
 3 files changed, 76 insertions(+), 1 deletions(-)
---
diff --git a/platform-demos/C/samples/spinner.py b/platform-demos/C/samples/spinner.py
new file mode 100644
index 0000000..41980a3
--- /dev/null
+++ b/platform-demos/C/samples/spinner.py
@@ -0,0 +1,43 @@
+from gi.repository import GLib
+from gi.repository import Gtk
+from gi.repository import Gdk
+import sys
+
+class MyWindow(Gtk.ApplicationWindow):
+    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)
+
+    # a signal from the keyboard (space) controls if the spinner stops/starts
+    def do_key_press_event(self, event):
+        keyname = Gdk.keyval_name(event.keyval)
+        if keyname == "space":
+            if self.spinner.get_property("active"):
+                self.spinner.stop()
+            else:
+                self.spinner.start()
+        return True
+
+class MyApplication(Gtk.Application):
+    def __init__(self):
+        Gtk.Application.__init__(self, application_id="org.example.MyApplication")
+
+    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/spinner.py.page b/platform-demos/C/spinner.py.page
new file mode 100644
index 0000000..777a617
--- /dev/null
+++ b/platform-demos/C/spinner.py.page
@@ -0,0 +1,30 @@
+<page xmlns="http://projectmallard.org/1.0/";
+      xmlns:xi="http://www.w3.org/2001/XInclude";
+      type="guide" style="task"
+      id="spinner.py">
+  <info>
+    <link type="guide" xref="beginner.py#display-widgets"/>
+    <revision version="0.1" date="2012-05-24" status="draft"/>
+
+    <credit type="author copyright">
+      <name>Marta Maria Casetti</name>
+      <email>mmcasetti gmail com</email>
+      <years>2012</years>
+    </credit>
+
+    <desc>A spinner animation</desc>
+  </info>
+
+  <title>Spinner</title>
+  <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>
+</page>
diff --git a/platform-demos/Makefile.am b/platform-demos/Makefile.am
index a02f3e1..e076b31 100644
--- a/platform-demos/Makefile.am
+++ b/platform-demos/Makefile.am
@@ -19,7 +19,7 @@ demo_sources = \
 	magic-mirror/magic-mirror.vala 		\
 	magic-mirror/magic-mirror-advanced.vala \
 	message-board/message-board.c 		\
-	photo-wall/photo-wall.c 		\		
+	photo-wall/photo-wall.c 		\
 	record-collection/record-collection.js 	\
 	samples/aboutdialog.py			\
 	samples/aboutdialog.vala		\
@@ -52,6 +52,7 @@ demo_sources = \
 	samples/progressbar.vala		\
 	samples/radiobutton.py			\
 	samples/radiobutton.vala		\
+	samples/spinner.py              \
 	samples/spinner.vala			\
 	samples/statusbar.vala			\
 	samples/switch.py			\
@@ -173,6 +174,7 @@ DOC_PAGES =				\
 	radiobutton.py.page		\
 	radiobutton.vala.page		\
 	record-collection.js.page	\
+    spinner.py.page         \
 	spinner.vala.page		\
 	statusbar.vala.page		\
 	switch.py.page			\



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