Quantcast
Channel: User spraff - Stack Overflow
Viewing all articles
Browse latest Browse all 67

ctrl-C to terminate a pyqt application with a QOpenGLWidget

$
0
0

My main file for a pyqt application looks like this:

#!/usr/bin/env python3from PyQt5.QtWidgets import QApplicationimport signalimport sysfrom main_window import MainWindowif __name__ == "__main__":  signal.signal(signal.SIGINT, signal.SIG_DFL)  app = QApplication([])  window = MainWindow()  window.show()  app.exec()

It works, and when I ctrl-c in the terminal (on Ubuntu) the application will terminate...

...unless it creates a QOpenGLWidget, in which case ctrl-C does nothing.

I tried this

def signal_handler(signum, frame):"""Handle SIGINT signal"""    print("\nReceived SIGINT, closing application...")    QApplication.instance().quit()if __name__ == "__main__":  signal.signal(signal.SIGINT, signal_handler)  ...

but signal_handler is never called.

How can I terminate a pyqt application using QOpenGLWidget using ctrl-C from the terminal?


Viewing all articles
Browse latest Browse all 67

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>