[Qgis-developer] QGIS, Python and Threads
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 ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] QGIS, Python and Threads
Hi Matthias, I had a similar problem a couple of weeks back. While I was unable to identify why my first attempt was failing I was able to produce a functioning implementation on the second attempt. I posted my problem (and later a working solution) over here. [1] Another gotcha to be aware of is that any python errors that occur in the other thread will be displayed in the Message Log, I find it useful to have this as a floating window during development. [1] http://gis.stackexchange.com/questions/45514/how-do-i-maintain-a-resposive-gui-using-qthread-with-pyqgis Good Luck,Kelly Thomas Date: Tue, 22 Jan 2013 10:33:16 +0100 From: kaot...@gmx.de 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? ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer
Re: [Qgis-developer] QGIS, Python and Threads
Another gotcha to be aware of is that any python errors that occur in the other thread will be displayed in the MessageLog, I find it useful to have this as a floating window during development. I think it's an indenting error.It looks like your code is indented with tabs, while the other code is indented with spaces. This happens to me all the time if I mix code from different sources. ___ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer