[gnome-devel-docs] tutorials python: button example without subclassing
- From: Tiffany Antopolski <antopolski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] tutorials python: button example without subclassing
- Date: Tue, 22 May 2012 22:32:49 +0000 (UTC)
commit 289e773dbad6e2f40465bb61e6c332e5f5f34c78
Author: Marta Maria Casetti <mmcasetti gmail com>
Date: Tue May 22 14:59:52 2012 +0100
tutorials python: button example without subclassing
platform-demos/C/samples/button.py | 11 +++++------
1 files changed, 5 insertions(+), 6 deletions(-)
---
diff --git a/platform-demos/C/samples/button.py b/platform-demos/C/samples/button.py
index 66b8879..e17def3 100644
--- a/platform-demos/C/samples/button.py
+++ b/platform-demos/C/samples/button.py
@@ -6,12 +6,12 @@ import sys
class MyWindow(Gtk.ApplicationWindow):
def __init__(self, app):
Gtk.Window.__init__(self, title="GNOME Button", application=app)
-
-class MyButton(Gtk.Button):
- def __init__(self):
- Gtk.Button.__init__(self, label="Click me", stock=None, use_underline=True)
+ button = Gtk.Button()
+ button.set_label("Click me")
+ button.connect("clicked", self.do_clicked)
+ self.add(button)
- def do_clicked(self):
+ def do_clicked(self, button):
print "You clicked me!"
class MyApplication(Gtk.Application):
@@ -22,7 +22,6 @@ class MyApplication(Gtk.Application):
win = MyWindow(self)
win.set_default_size(250, 50)
win.set_position(Gtk.WindowPosition.CENTER)
- win.add(MyButton())
win.show_all()
def do_startup (self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]