[gnome-devel-docs] tutorials python: dialog window
- From: Tiffany Antopolski <antopolski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] tutorials python: dialog window
- Date: Tue, 22 May 2012 22:32:28 +0000 (UTC)
commit b47568c10f0122ac6471bbe0252bdfbc70eb8c53
Author: Marta Maria Casetti <mmcasetti gmail com>
Date: Mon May 14 09:21:34 2012 +0100
tutorials python: dialog window
platform-demos/C/dialog.py.page | 25 ++++++++++++++++++++
platform-demos/C/samples/dialog.py | 45 ++++++++++++++++++++++++++++++++++++
2 files changed, 70 insertions(+), 0 deletions(-)
---
diff --git a/platform-demos/C/dialog.py.page b/platform-demos/C/dialog.py.page
new file mode 100644
index 0000000..a86d5de
--- /dev/null
+++ b/platform-demos/C/dialog.py.page
@@ -0,0 +1,25 @@
+<page xmlns="http://projectmallard.org/1.0/"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ type="guide" style="task"
+ id="dialog.py">
+ <info>
+ <link type="guide" xref="beginner.py#windows"/>
+ <revision version="0.1" date="2012-04-07" status="stub"/>
+
+ <credit type="author copyright">
+ <name>Marta Maria Casetti</name>
+ <email>mmcasetti gmail com</email>
+ <years>2012</years>
+ </credit>
+
+ <desc>A popup window</desc>
+ </info>
+
+ <title>Dialog</title>
+ <media type="image" mime="image/png" src="media/dialog.png"/>
+ <p>A dialog with the response signal hooked up to a callback function.</p>
+
+ <code mime="text/x-python" style="numbered">
+<xi:include href="samples/dialog.py" parse="text"><xi:fallback/></xi:include></code>
+
+</page>
diff --git a/platform-demos/C/samples/dialog.py b/platform-demos/C/samples/dialog.py
new file mode 100644
index 0000000..498d16d
--- /dev/null
+++ b/platform-demos/C/samples/dialog.py
@@ -0,0 +1,45 @@
+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="GNOME Button", application=app)
+ self.set_default_size(250, 50)
+
+ button = Gtk.Button("Click me")
+ button.connect("clicked", self.on_button_click)
+ self.add(button)
+ button.show()
+
+ def on_button_click(self, *args):
+ dialog = Gtk.Dialog("A Gtk+ Dialog", self, Gtk.DialogFlags.DESTROY_WITH_PARENT)
+ dialog.add_button(button_text="OK", response_id=Gtk.ResponseType.OK)
+ # otherwise, we can add buttons as
+ # dialog.add_button(button_text="Another button", response_id=42)
+ # where the response_id is any integer
+ content_area = dialog.get_content_area()
+ label = Gtk.Label("This demonstrates a dialog with a label")
+ content_area.add(label)
+ label.show()
+ dialog.connect("response", self.on_response)
+ dialog.show_all()
+
+ def on_response(self, widget, response_id):
+ print "response_id is", response_id
+
+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]