Help with pysignals with QT
Boudewijn Rempt
boud at rempt.xs4all.nl
Sat Jan 19 14:39:42 EST 2002
root <root at localhost.localdomain> wrote:
> I have been trying various permutations around this for several days
> without success, I dont know if the signal isn't being emitd or if theres
> something wrong with my connect statement.
Here's a working version. (I've taken the liberty of
changing confusing statements like test=test() to
test=Test().)
from qt import *
import sys
class Test(QObject):
def __init__(self):
QObject.__init__(self)
def send(self):
print "about to emit"
self.emit(PYSIGNAL("pySig"),())
print "emit"
class Message:
def hello(self):
print "The slot called"
class Join:
def __init__(self):
print "in join"
self.m = Message()
self.t = Test()
QObject.connect(self.t, PYSIGNAL('pySig'),
self.m.hello)
print "connected"
j = Join()
j.t.send()
First, you don't need the QApplication object. QObject.connect
is a static in C++, and a class method in Python, so you
call it directly. Secondly, you initially didn't call send() on
the right object.
I take it you know already about the book at http://www.opendocs.org?
It should have been printed now, and I expect to be very busy setting
up the web forum with downloads of updated code, errata and so on.
--
Boudewijn Rempt | http://www.valdyas.org
More information about the Python-list
mailing list