From 21a75cb1ada2be6f6d58bffdd3aa2ce34052ee58 Mon Sep 17 00:00:00 2001 From: Andreas Bolin <2535580+andbo467@users.noreply.github.com> Date: Fri, 8 Jul 2022 03:21:47 +0200 Subject: [PATCH] workspace dump --- b_asic/scheduler-gui/main_window.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/b_asic/scheduler-gui/main_window.py b/b_asic/scheduler-gui/main_window.py index 06be3657..33e82c58 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() -- GitLab