[PyQt] thread in pyqt ... simple example needed
Arnold Krille
arnold at arnoldarts.de
Sun Apr 5 22:10:23 BST 2009
On Sunday 05 April 2009 21:29:44 Hazen Babcock wrote:
> I'd suggest expanding your MyThread class to something like this:
> class MyThread(QtCore.QThread):
> def __init__(self, parent = None):
> QtCore.QThread.__init__(self, parent)
> self.running = 1
> def run(self):
> n = 0
> step = 1
> while self.running:
> n += step
> print n
> self.msleep(100)
> def stop(self):
> self.running = 0
> You should also look at the QtCore.QMutex() class, which provides a way
> to synchronize (via locking) between the thread process and other
> processes.
Another reason while this will not work as expected is the Big Intepreter
Lock. Unless QThread releases the BIL in its *sleep-functions, the thread will
block the execution of the main-thread...
Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090405/86b21c8e/attachment.bin
More information about the PyQt
mailing list