Last active
August 27, 2020 09:22
-
-
Save DataSolveProblems/8758c82d68b8978ec4b762e0d6883c74 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
from PyQt5.QtWidgets import (QApplication, QWidget, QMessageBox) | |
class MainWindow(QWidget): | |
def __init__(self): | |
super().__init__() | |
def closeEvent(self, event): | |
reply = QMessageBox.question(self, 'Window Close', 'Are you sure you want to close the window?', | |
QMessageBox.Yes | QMessageBox.No, QMessageBox.No) | |
if reply == QMessageBox.Yes: | |
event.accept() | |
print('Window closed') | |
else: | |
event.ignore() | |
if __name__ == '__main__': | |
app = QApplication(sys.argv) | |
demo = MainWindow() | |
demo.show() | |
sys.exit(app.exec_()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment