GUI with QThread crashes with -1073740791 (0xC0000409)

-1

I'm building app GUI using PyQt, and there is a function that I need to run in back ground so I'm using QThread (see code below). I'm getting "Process finished with exit code -1073740791 (0xC0000409)"

How can this issue be solved ? Thank you

import time

from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout
from PyQt5.QtCore import pyqtSignal, QThread
import sys

class MyApp(QWidget):
    def __init__(self):
        super(QWidget, self).__init__()
        btn = QPushButton('Run')
        layout = QVBoxLayout()
        layout.addWidget(btn)
        btn.clicked.connect(self.my_function)
        self.setLayout(layout)

    def my_function(self):
        my_task = Task()
        my_task.done_signal.connect(self.done)
        my_task.start()

    def done(self):
        print('done')


class Task(QThread):
    done_signal = pyqtSignal()

    def run(self):
        # Do some work here
        time.sleep(3)
        self.done_signal.emit()


if __name__ == '__main__':
    app = QApplication(sys.argv)
    w = MyApp()
    w.show()
    sys.exit(app.exec_())
python
pyqt
qthread
asked on Stack Overflow Jun 24, 2019 by neferjina • edited Jun 24, 2019 by eyllanesc

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0