I want to create threads in PyQt4 (for normal use GUI).
Make thread class:
class solveThread(QtCore.QThread):
def run(self):
<what do you want doing>
Check for use thread with same name and kill it if yes:
if (hasattr(self,'s1')):
del(self.s1)
self.s1=solveThread()
If I want terminate thread by button, I use variable self.isExit=0 in infinite while loop (I don't use Thread.terminate() ). And I use refresh GUI each 5-10 sec (otherwise my GIU is freezing).
Make thread class:
class solveThread(QtCore.QThread):
def run(self):
<what do you want doing>
Check for use thread with same name and kill it if yes:
if (hasattr(self,'s1')):
del(self.s1)
self.s1=solveThread()
If I want terminate thread by button, I use variable self.isExit=0 in infinite while loop (I don't use Thread.terminate() ). And I use refresh GUI each 5-10 sec (otherwise my GIU is freezing).
Комментариев нет:
Отправить комментарий