Hi everyone,

I'm experimenting with PyQt4 signals. According to the documentation, any Python callable can be used as a slot. However, I can't get closures to work as I would expect them to. Here's some sample code that exercises the situation:

from PyQt4 import QtCore

#!/usr/bin/env python

class A(QtCore.QObject):
    def __init__(self):
        QtCore.QObject.__init__(self)
    def makeClosure(self, x):
        def f():
            print x
        return f

a = A()
a.connect(a, QtCore.SIGNAL("testClosure"), a.makeClosure(5))

a.makeClosure(6)()

a.emit(QtCore.SIGNAL("testClosure"))

Executing this only prints "6" to stdout on my Intel MacBook running PyQt4.

PyQt4 version: mac-gpl-snapshot-20060604
sip version: sip-snapshot-20060525
Qt version: 4.1.3

Is this a known issue? If any more info is needed to reproduce this, let me know.

Thank you very much in advance,
-carlos

_______________________________________________
PyKDE mailing list    [email protected]
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde

Reply via email to