Note that there are some explanatory texts on larger screens.

plurals
  1. POHow run two different threads simultaneously in pyqt
    primarykey
    data
    text
    <p>I have a situation where i need to start two threads one after the other. I tried the following code snippet, here i could able to start the Thread12 but not able to start Thread2. How can i start both....? How to start 2 threads one ofter the other...?</p> <p><strong>Code snippet</strong></p> <pre><code>class Thread1(QtCore.QThread): Thread1Signal = QtCore.pyqtSignal(str) def __init__(self): super(Thread1, self).__init__() def run(self): print 'Thread1 started' While True: #some statments if Condition: Thread1Signal.emit('Yes') else: Thread1Signal.emit('No') class Thread2(QtCore.QThread): Thread2Signal = QtCore.pyqtSignal(str) def __init__(self): super(Thread2, self).__init__() def run(self): print 'Thread2 started' While True: #some statments if Condition: Thread2Signal.emit('Yes') else: Thread2Signal.emit('No') class MainClass(QtCore.QObject): MainSignal1 = QtCore.pyqtSignal(str) MainSignal2 = QtCore.pyqtSignal(str) def __init__(self): super(MainClass, self).__init__() Threadinstance1 = Thread1() Threadinstance1.Thread1Signal.connect(MainSignal1) Threadinstance2 = Thread2() Threadinstance2.Thread2Signal.connect(MainSignal2) def start(self): Threadinstance1.start() Threadinstance2.start() #Thread2 never starts. def signal1called(s): print s def signal2called(s): print s if __name__=='__main__': app = AtGui.QApplication(sys.argv) temp = MainClass() temp.MainSignal1.connect(signal1called) temp.MainSignal2.connect(signal2called) temp.start() sys.exit(app.exec()_) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload