PyQT Qthread stuck main app

D

daved170

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()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,832
Latest member
GlennSmall

Latest Threads

Top