[kupfer] helplib: Add doctest for gobject_connect_weakly
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [kupfer] helplib: Add doctest for gobject_connect_weakly
- Date: Wed, 16 Sep 2009 14:22:18 +0000 (UTC)
commit 81ef275959f3932aa9193e003a85e091f5a232b0
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Tue Sep 15 05:53:48 2009 +0200
helplib: Add doctest for gobject_connect_weakly
kupfer/helplib.py | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/helplib.py b/kupfer/helplib.py
index 14b873b..d79e731 100644
--- a/kupfer/helplib.py
+++ b/kupfer/helplib.py
@@ -148,5 +148,21 @@ class GobjectWeakCallback (WeakCallback):
def gobject_connect_weakly(sender, signal, mcallback, *user_args):
"""Connect weakly to GObject @sender's @signal,
with a callback method @mcallback
+
+ >>> import gtk
+ >>> btn = gtk.Button()
+ >>> class Handler (object):
+ ... def handle(self): pass
+ ... def __del__(self): print "deleted"
+ ...
+ >>> h = Handler()
+ >>> gobject_connect_weakly(btn, "clicked", h.handle)
+ >>> del h
+ deleted
+ >>>
"""
GobjectWeakCallback._connect(sender, signal, mcallback, *user_args)
+
+if __name__ == '__main__':
+ import doctest
+ doctest.testmod()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]