[gnome-devel-docs] python samples: Added Gtk.Grid python example.
- From: Tiffany Antopolski <antopolski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] python samples: Added Gtk.Grid python example.
- Date: Sat, 21 Apr 2012 02:22:29 +0000 (UTC)
commit 11c75033982bb706091a12539d1dc4a333a8b4a2
Author: Tiffany Antopolski <tiffany antopolski gmail com>
Date: Fri Apr 20 22:04:23 2012 -0400
python samples: Added Gtk.Grid python example.
An example using Gtk.Application.
platform-demos/C/beginner.py.page | 11 ++++++
platform-demos/C/grid.py.page | 65 +++++++++++++++++++++++++++++++++++++
platform-demos/C/samples/grid.py | 31 +++++++++++++++++
platform-demos/Makefile.am | 1 +
4 files changed, 108 insertions(+), 0 deletions(-)
---
diff --git a/platform-demos/C/beginner.py.page b/platform-demos/C/beginner.py.page
index 97049ec..55c6a07 100644
--- a/platform-demos/C/beginner.py.page
+++ b/platform-demos/C/beginner.py.page
@@ -33,6 +33,17 @@
<section id="samples">
<title>Code samples</title>
+
+ <p>
+ To run the code samples:
+ </p>
+ <steps>
+ <item><p>Copy and paste the code into <var>filename</var>.py</p></item>
+ <item><p>In the terminal type:</p>
+ <screen>python <var>filename</var>.py</screen>
+ </item>
+ </steps>
+
<section id="windows"><title>Windows</title>
<p></p>
</section>
diff --git a/platform-demos/C/grid.py.page b/platform-demos/C/grid.py.page
new file mode 100644
index 0000000..b139feb
--- /dev/null
+++ b/platform-demos/C/grid.py.page
@@ -0,0 +1,65 @@
+<page xmlns="http://projectmallard.org/1.0/"
+ type="guide" style="task"
+ id="grid.py">
+ <info>
+ <link type="guide" xref="beginner.py#layout"/>
+ <revision version="0.1" date="2012-02-21" status="stub"/>
+
+ <credit type="author copyright">
+ <name>Tiffany Antopolski</name>
+ <email>tiffany antopolski gmail com</email>
+ <years>2012</years>
+ </credit>
+
+ <desc>Pack widgets in rows and columns</desc>
+ </info>
+
+ <title>Grid widget</title>
+
+ <media type="image" mime="image/png" src="media/grid.png"/>
+ <p>A button widget connected to a progress bar.</p>
+
+ <code mime="text/javascript" style="numbered"><![CDATA[
+from gi.repository import Gtk
+import sys
+
+class GridWindow(Gtk.ApplicationWindow):
+ def __init__(self, app):
+ Gtk.Window.__init__(self, title="Grid Example", application=app)
+
+ grid = Gtk.Grid()
+ button = Gtk.Button(label="Button")
+
+ self.add(grid)
+ grid.attach(button, 1, 1, 1, 1)
+ self.progress_bar = Gtk.ProgressBar()
+ grid.attach_next_to(self.progress_bar, button, 3, 1, 1)
+
+ button.connect("clicked", self.button_clicked_cb)
+
+ def button_clicked_cb(self, widget):
+ self.progress_bar.pulse()
+
+class GridApplication(Gtk.Application):
+ def __init__(self):
+ Gtk.Application.__init__(self, application_id="org.gtk.example.grid")
+
+ def do_activate(self):
+ win = GridWindow(self)
+ win.show_all()
+
+app = GridApplication()
+exit_status = app.run(sys.argv)
+sys.exit(exit_status)
+]]></code>
+<p>
+ In this sample we used the following:
+</p>
+<list>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkApplication.html">Gtk.Application</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkApplicationWindow.html">Gtk.ApplicationWindow</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkGrid.html">Gtk.Grid</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkProgressBar.html">Gtk.ProgressBar</link></p></item>
+ <item><p><link href="button.py.page">Gtk.Button</link></p></item>
+</list>
+</page>
diff --git a/platform-demos/C/samples/grid.py b/platform-demos/C/samples/grid.py
new file mode 100644
index 0000000..aaf81ba
--- /dev/null
+++ b/platform-demos/C/samples/grid.py
@@ -0,0 +1,31 @@
+from gi.repository import Gtk
+import sys
+
+class GridWindow(Gtk.ApplicationWindow):
+ def __init__(self, app):
+ Gtk.Window.__init__(self, title="Grid Example", application=app)
+
+ grid = Gtk.Grid()
+ button = Gtk.Button(label="Button")
+
+ self.add(grid)
+ grid.attach(button, 1, 1, 1, 1)
+ self.progress_bar = Gtk.ProgressBar()
+ grid.attach_next_to(self.progress_bar, button, 3, 1, 1)
+
+ button.connect("clicked", self.button_clicked_cb)
+
+ def button_clicked_cb(self, widget):
+ self.progress_bar.pulse()
+
+class GridApplication(Gtk.Application):
+ def __init__(self):
+ Gtk.Application.__init__(self, application_id="org.gtk.example.grid")
+
+ def do_activate(self):
+ win = GridWindow(self)
+ win.show_all()
+
+app = GridApplication()
+exit_status = app.run(sys.argv)
+sys.exit(exit_status)
diff --git a/platform-demos/Makefile.am b/platform-demos/Makefile.am
index 72a37af..0a309ff 100644
--- a/platform-demos/Makefile.am
+++ b/platform-demos/Makefile.am
@@ -65,6 +65,7 @@ DOC_PAGES = \
entry.js.page \
getting-ready.page \
grid.js.page \
+ grid.py.page \
GtkApplication.vala.page \
guitar-tuner.c.page \
guitar-tuner.cpp.page \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]