I have a problem with opening a MainWindow in a second thread in my python app. I have an Application as default menu and i want to control it by mouse and voice. To do it I need to create an object of MainWindow in my SpeechRecognition class and i need to do it in a thread. I was trying to do it like here: https://realpython.com/python-pyqt-qthread/?fbclid=IwAR10gvY4I4nmRrifpvLM_zykWimMIc8hjUj_0-1epMT4ccSwrLxEwN2jtH4
but when i create a MainWindow thread the window is freezed and can click nothing.
class Recognizer(QObject):
def run(self):
self.run_Thread()
while(True):
#RECOGNITION FUNCTIONS
def run_Thread(self):
self.thread = QThread()
self.menu = MainWindow()
self.menu.moveToThread(self.thread)
self.thread.started.connect(self.menu.run)
self.menu.finished.connect(self.thread.quit)
self.menu.finished.connect(self.menu.deleteLater)
self.thread.finished.connect(self.thread.deleteLater)
self.thread.start()
class MainWindow(QObject):
finished = pyqtSignal()
progress = pyqtSignal(int)
#REST OF CODE
I don't know how to do it properly.