PyQT Qthread stuck main app

daved170 daved170 at gmail.com
Tue Sep 15 12:59:35 CEST 2009


Hi everybody,
I've got a simple GUI app written in python and pyqt.
I'm having 2 buttons - "start" and "stop"

start calls a function that start a thread and stop stops it.

my problem is that when start is pusshed the entire window stuck and
it's impossible to push the STOP button and even when it looks like
it's been pushed it actually don't do anything.

any idea how to fix it?
Thanks Dave


class myThread(QtCore.QThread):
   def__init__(self):
      self.alive = 1

   def run(self):
      while self.alive:
           print "Alive"
      print "Not Alive"

   def stop(self):
       print "stop pushed"
       self.alive = 0

class GUI(QtGui.QMainWindow):
      def __init__(self):
          .... # all kind of initialization

     @QtCore.pyqtSignature("start")
     def on_start_clicked(self):
         self.cThread = myThread()
         self.cThread.start()

     @QtCore.pyqtSignature("stop")
     def on_stop_clicked(self):
         self.cThread.stop()



More information about the Python-list mailing list