[gnome-devel-docs] tutorials python: a window with a button which emits a signal when clicked



commit d511418d50f6a57ad6d4a5ea88607fba9ebe6620
Author: Marta Maria Casetti <mmcasetti gmail com>
Date:   Fri May 4 21:51:48 2012 +0100

    tutorials python: a window with a button which emits a signal when clicked

 platform-demos/C/button.py.page    |   26 ++++++++++++++++++++++++++
 platform-demos/C/samples/button.py |   21 +++++++++++++++++++++
 2 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/platform-demos/C/button.py.page b/platform-demos/C/button.py.page
new file mode 100644
index 0000000..e00f0b0
--- /dev/null
+++ b/platform-demos/C/button.py.page
@@ -0,0 +1,26 @@
+<page xmlns="http://projectmallard.org/1.0/";
+      xmlns:xi="http://www.w3.org/2001/XInclude";
+      type="guide" style="task"
+      id="button.py">
+  <info>
+    <link type="guide" xref="beginner.py#buttons"/>
+    <revision version="0.1" date="2012-05-05" status="stub"/>
+
+    <credit type="author copyright">
+      <name>Marta Maria Casetti</name>
+      <email>mmcasetti gmail com</email>
+      <years>2012</years>
+    </credit>
+
+    <desc>A button widget which emits a signal when clicked</desc>
+  </info>
+
+  <title>Button widget</title>
+
+  <media type="image" mime="image/png" src="media/button.png"/>
+  <p>A button widget connected to a simple callback function.</p>
+
+<code mime="text/x-python" style="numbered">
+<xi:include href="samples/button.py" parse="text"><xi:fallback/></xi:include>
+</code>
+</page>
diff --git a/platform-demos/C/samples/button.py b/platform-demos/C/samples/button.py
new file mode 100644
index 0000000..a6dcd26
--- /dev/null
+++ b/platform-demos/C/samples/button.py
@@ -0,0 +1,21 @@
+from gi.repository import Gtk
+
+class ButtonWindow(Gtk.Window):
+
+    def __init__(self):
+        Gtk.Window.__init__(self, title="GNOME Button")
+        
+        self.set_default_size(250, 50)
+        self.set_position(Gtk.WindowPosition.CENTER)
+        
+        self.button = Gtk.Button(label="Click me")
+        self.button.connect("clicked", self.button_clicked)
+        self.add(self.button)
+    
+    def button_clicked(self, widget):
+        print "\"Click me\" button was clicked"
+        
+win = ButtonWindow()
+win.connect("destroy", Gtk.main_quit)
+win.show_all()
+Gtk.main()



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