Handled close actions

This commit is contained in:
Marcel Kapfer 2020-04-30 10:27:08 +02:00
parent 09f8a93da4
commit efae523a4b
Signed by: mmk2410
GPG key ID: CADE6F0C09F21B09

14
init.py
View file

@ -10,15 +10,27 @@ MIT License
""" """
import sys import sys
from PyQt5.QtWidgets import QApplication, QMainWindow from PyQt5.QtWidgets import QApplication, QMainWindow, QMessageBox
from ui_mainwindow import Ui_MainWindow from ui_mainwindow import Ui_MainWindow
class MainWindow(QMainWindow, Ui_MainWindow): class MainWindow(QMainWindow, Ui_MainWindow):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs) super(MainWindow, self).__init__(*args, **kwargs)
self.setupUi(self) self.setupUi(self)
# Connect close actions
self.b_cancel.clicked.connect(self.close)
self.ma_close.triggered.connect(self.close)
self.show() 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__": if __name__ == "__main__":
app = QApplication([]) app = QApplication([])
app.setApplicationName("WikiCookBook") app.setApplicationName("WikiCookBook")