[Qgis-developer] QGIS, Python and Threads
Matthias Ludwig
kaotika at gmx.de
Tue Jan 22 01:33:16 PST 2013
Hello,
I try to write a plugin in python. The plugin will be part of a complex plugin and will make a longer running numpy calculation. I want the GUI to be responsive during the calculation. As a basis I used Aaron Racicots(http://svn.reprojected.com/qgisplugins/trunk/threading_demo/) threading example and modified the run code (the calculation is only an example). Unfortunately it does not what I want it to do...it hangs during calculation. Did I missed a thing?
import numpy
class TestThread(QThread):
def __init__(self, parentThread,parentObject):
QThread.__init__(self, parentThread)
self.parent = parentObject
self.running = False
self.total = 0
self.currentCount = 0
def __del__(self):
self.running = False
self.wait()
def run(self):
self.running = True
A = numpy.random.random((2000,2000))
b = numpy.random.random((2000,1))
x = numpy.linalg.solve(A, b)
print x.trace()
self.emit(SIGNAL("runFinished(PyQt_PyObject)"),"Pass")
self.stop()
def stop(self):
self.running = False
def getUpdate(self):
return self.currentCount
More information about the Qgis-developer
mailing list