Thanks all for the quick follow-up ! It's good to hear that what I have in mind *should* work. However, I'm actually struggling a bit with the implementation. I have attached a very simple test-case creating a simple (pyqt5) app. If I call the `main()` function rather than `run_app()` directly, the script fails: First I see the error / warning message
`WARNING: QApplication was not created in the main() thread.` the main window appears, but isn't fully constructed and it doesn't look like the event loop is ever started. (The window's content isn't updated, no button appears, and the app isn't receiving input events.) What am I doing wrong ? Thanks, ...ich hab' noch einen Koffer in Berlin...
from PyQt5.QtCore import QSize, Qt from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton import threading import time import sys class MainWindow(QMainWindow): def __init__(self): super().__init__() self.setWindowTitle("Test App") button = QPushButton("quit") self.setCentralWidget(button) button.clicked.connect(QApplication.quit) def run_app(): app = QApplication(sys.argv) window = MainWindow() window.show() print('entering event loop') app.exec_() print('done') def main(): thread = threading.Thread(target=run_app) thread.start() # TODO: do some work here thread.join() if __name__ == '__main__': main() #run_app()
_______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest