old style signal/slot works in this way. Note: I'm just joined in this mailing list and don't know main issue for this topic. sorry if it's not related to main issue. :)
import sys from PyQt4 import QtCore, QtGui
class Runnable(QtCore.QRunnable):
lock = QtCore.QReadWriteLock()
counter = 0
def __init__(self, repeat):
super(Runnable, self).__init__()
self.repeat = repeat
self.obj = QtCore.QObject()
def run(self):
for i in xrange(self.repeat):
Runnable.lock.lockForWrite()
counter = Runnable.counter = Runnable.counter + 1
Runnable.lock.unlock()
self.obj.emit(QtCore.SIGNAL("testSignal(int,int,int,int)"), 1, 2, 3, counter)
class Win(QtGui.QPushButton):
def __init__(self, repeat):
super(Win, self).__init__("Push me")
self.repeat = repeat
self.tp = QtCore.QThreadPool()
self.clicked.connect(self.slotClicked)
self.addAction(QtGui.QAction(self,
shortcut = QtGui.QKeySequence.Quit,
triggered = self.close))
def slotClicked(self):
for i in xrange(self.repeat):
runnable = Runnable(self.repeat)
self.connect(runnable.obj, QtCore.SIGNAL("testSignal(int,int,int,int)"), self, QtCore.SLOT("oldSlotTestSignal(int,int,int,int)"))
self.tp.start(runnable)
@QtCore.pyqtSlot(int, int, int, int)
def oldSlotTestSignal(self, *args):
print "Returning from runnable", args
if __name__ == '__main__':
try:
repeat = int(sys.argv[1])
except:
repeat = 10
app = QtGui.QApplication(sys.argv)
w = Win(repeat)
w.show()
sys.exit(app.exec_())
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
