Posts

Showing posts with the label Programming

PyQT5 Exit Confirmation

Image
This is a small post explaining how you can add an exit confirmation to your PyQT5 code. Simply add this code to your MainWindow class: Remember to: [PyQT5] from PyQt5.QtWidgets import QMessageBox [PySide2] from PySide2.QtWidgets import QMessageBox def closeEvent(self, event):       quit_msg = "Are you sure you want to exit the program?"       reply = QMessageBox.question(self, 'Message',                      quit_msg, QMessageBox.Yes, QMessageBox.No)       if reply == QMessageBox.Yes:          event.accept()       else:          event.ignore()   Ubuntu Message Box: