diff --git a/b_asic/scheduler-gui/main_window.py b/b_asic/scheduler-gui/main_window.py index 06be36575ea03847f35069667e6a3978c609d13f..33e82c58d91da0b49220ba0cf5dd53855d2d5e10 100644 --- a/b_asic/scheduler-gui/main_window.py +++ b/b_asic/scheduler-gui/main_window.py @@ -2,6 +2,8 @@ """B-ASIC Scheduler-gui Module. Contains the scheduler-gui class for scheduling operations in an SFG. + +Start main-window with start_gui(). """ @@ -16,11 +18,11 @@ import qtpy from qtpy import uic, QtCore, QtGui, QtWidgets from qtpy.QtCore import Qt, Slot, QSettings from qtpy.QtGui import QCloseEvent -from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox +from qtpy.QtWidgets import QApplication, QMainWindow, QMessageBox, QAbstractButton # QGraphics and QPainter imports from qtpy.QtWidgets import ( - QGraphicsView, QGraphicsScene, + QGraphicsView, QGraphicsScene, QGraphicsWidget, QGraphicsLayout, QGraphicsLinearLayout, QGraphicsGridLayout, QGraphicsLayoutItem, QGraphicsAnchorLayout, QGraphicsItem, QGraphicsItemGroup, QGraphicsItemAnimation ) @@ -173,20 +175,30 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.menu_node_info.setChecked(True) + ################ #### Events #### ################ def _close_event(self, event: QCloseEvent) -> None: """Replace QMainWindow default closeEvent(QCloseEvent) event""" - ret = QMessageBox.question(self, self.tr("Application"), - self.tr("Do you want to exit?")) + + box = QMessageBox(self) + box.setWindowTitle(self.tr('Confirm Exit')) + box.setText('<h3>' + self.tr('Confirm Exit') + '</h3><p><br>' + + self.tr('Are you sure you want to exit?') + + ' <br></p>') + box.setIcon(QMessageBox.Question) + box.setStandardButtons(QMessageBox.Yes | QMessageBox.No) + box.setButtonText(QMessageBox.Yes, self.tr("&Exit")) + box.setButtonText(QMessageBox.No, self.tr("&Cancel")) + + ret = box.exec_() if ret == QMessageBox.StandardButton.Yes: event.accept() else: event.ignore() - ################################# #### Helper member functions #### ################################# @@ -204,7 +216,6 @@ class MainWindow(QMainWindow, Ui_MainWindow): self.statusbar.showMessage(msg) - def start_gui(): app = QApplication(sys.argv) window = MainWindow()