From efae523a4b22538ba6bf263be314f97ee681539d Mon Sep 17 00:00:00 2001 From: Marcel Kapfer Date: Thu, 30 Apr 2020 10:27:08 +0200 Subject: [PATCH] Handled close actions --- init.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/init.py b/init.py index 296a004..51bfb9c 100644 --- a/init.py +++ b/init.py @@ -10,15 +10,27 @@ MIT License """ import sys -from PyQt5.QtWidgets import QApplication, QMainWindow +from PyQt5.QtWidgets import QApplication, QMainWindow, QMessageBox from ui_mainwindow import Ui_MainWindow class MainWindow(QMainWindow, Ui_MainWindow): def __init__(self, *args, **kwargs): super(MainWindow, self).__init__(*args, **kwargs) self.setupUi(self) + + # Connect close actions + self.b_cancel.clicked.connect(self.close) + self.ma_close.triggered.connect(self.close) + self.show() + def close(self): + reply = QMessageBox.question(self, "Sicher?", + "Möchten Sie wirklich schließen?", + QMessageBox.Yes | QMessageBox.No, QMessageBox.No) + if reply == QMessageBox.Yes: + sys.exit(0) + if __name__ == "__main__": app = QApplication([]) app.setApplicationName("WikiCookBook")