[gnome-devel-docs] tutorials python: checkbutton example
- From: Tiffany Antopolski <antopolski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] tutorials python: checkbutton example
- Date: Tue, 22 May 2012 22:32:33 +0000 (UTC)
commit ea82c239541d39cd0fc6c2610c9ced3fad5ae088
Author: Marta Maria Casetti <mmcasetti gmail com>
Date: Tue May 22 14:55:28 2012 +0100
tutorials python: checkbutton example
platform-demos/C/checkbutton.py.page | 32 ++++++++++++++++++++++++
platform-demos/C/samples/checkbutton.py | 40 +++++++++++++++++++++++++++++++
2 files changed, 72 insertions(+), 0 deletions(-)
---
diff --git a/platform-demos/C/checkbutton.py.page b/platform-demos/C/checkbutton.py.page
new file mode 100644
index 0000000..d2eed61
--- /dev/null
+++ b/platform-demos/C/checkbutton.py.page
@@ -0,0 +1,32 @@
+<page xmlns="http://projectmallard.org/1.0/"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ type="guide" style="task"
+ id="checkbutton.py">
+ <info>
+ <link type="guide" xref="beginner.py#buttons"/>
+ <revision version="0.1" date="2012-05-09" status="draft"/>
+
+ <credit type="author copyright">
+ <name>Marta Maria Casetti</name>
+ <email>mmcasetti gmail com</email>
+ <years>2012</years>
+ </credit>
+
+ <desc>A toggle button in a window</desc>
+ </info>
+
+ <title>CheckButton</title>
+ <media type="image" mime="image/png" src="media/checkbutton.png"/>
+ <p>This CheckButton toggles the title.</p>
+
+<code mime="text/x-python" style="numbered"><xi:include href="samples/checkbutton.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/GtkApplication.html">GtkApplication</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkApplicationWindow.html">GtkApplicationWindow</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkToggleButton.html">GtkToggleButton</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkCheckButton.html">GtkCheckButton</link></p></item>
+</list>
+</page>
diff --git a/platform-demos/C/samples/checkbutton.py b/platform-demos/C/samples/checkbutton.py
new file mode 100644
index 0000000..8df66c9
--- /dev/null
+++ b/platform-demos/C/samples/checkbutton.py
@@ -0,0 +1,40 @@
+from gi.repository import GLib
+from gi.repository import Gtk
+from gi.repository import Gio
+import sys
+
+class MyWindow(Gtk.ApplicationWindow):
+ def __init__(self, app):
+ Gtk.Window.__init__(self, title="CheckButton Example", application=app)
+ self.set_default_size(300, 100)
+ self.set_border_width(10)
+
+ # a new checkbutton with a label, connected with the callback
+ button = Gtk.CheckButton.new_with_label("Show Title")
+ button.connect("toggled", self.toggled_cb)
+ # default: is active
+ button.set_active(True)
+
+ self.add(button)
+
+ # the button operates on the window
+ def toggled_cb(self, button):
+ if button.get_active():
+ self.set_title("CheckButton Example")
+ else:
+ self.set_title("")
+
+class MyApplication(Gtk.Application):
+ def __init__(self):
+ Gtk.Application.__init__(self, application_id="org.gtk.example.grid")
+
+ 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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]