Created
October 21, 2018 13:50
-
-
Save dybber/f27c98fc164d9bb50483b7af68b675d7 to your computer and use it in GitHub Desktop.
PySide2 Exception not raised to the user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import PySide2.QtCore as QtCore | |
import PySide2.QtWidgets as QtWidgets | |
class Worker(QtCore.QObject): | |
on_start = QtCore.Signal() | |
def on_start(self): | |
print("This line is executed!") | |
raise Exception(".. but this exception is not raised") | |
def main(): | |
app = QtWidgets.QApplication(sys.argv) | |
label = QtWidgets.QLabel("Hello World!") | |
label.show() | |
worker_thread = QtCore.QThread() | |
worker = Worker() | |
worker.moveToThread(worker_thread) | |
worker_thread.started.connect(worker.on_start) | |
worker_thread.finished.connect(worker_thread.deleteLater) | |
worker_thread.start() | |
app.exec_() | |
# Application was closed, clean up and exit | |
worker.deleteLater() | |
worker_thread.deleteLater() | |
sys.exit(0) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment