From faffebe3612038c83079881be03215fde8efc676 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr> Date: Mon, 19 Jun 2023 11:53:05 +0200 Subject: [PATCH] SolverLog: Add code base. --- src/Model/Study.py | 6 ++-- src/View/CheckList/Window.py | 5 +-- src/View/MainWindow.py | 11 +++++- src/View/RunSolver/Window.py | 66 ++++++++++++++++++++++++++++++++++-- src/View/ui/SolverLog.ui | 12 ++++++- 5 files changed, 91 insertions(+), 9 deletions(-) diff --git a/src/Model/Study.py b/src/Model/Study.py index 311217ab..a07d32c4 100644 --- a/src/Model/Study.py +++ b/src/Model/Study.py @@ -37,9 +37,9 @@ class Study(Serializable): lst = [ StudyNetworkReachChecker(), StudyGeometryChecker(), - DummyOK(), - DummyWARNING(), - DummyERROR(), + # DummyOK(), + # DummyWARNING(), + # DummyERROR(), ] return lst diff --git a/src/View/CheckList/Window.py b/src/View/CheckList/Window.py index 88b0294d..14259cf9 100644 --- a/src/View/CheckList/Window.py +++ b/src/View/CheckList/Window.py @@ -40,6 +40,7 @@ class CheckListWindow(ASubMainWindow, ListedSubWindow): self._study = study self._config = config self._solver = solver + self._parent = parent super(CheckListWindow, self).__init__( name=self._title, ui="CheckList", parent=parent @@ -139,7 +140,7 @@ class CheckListWindow(ASubMainWindow, ListedSubWindow): self.find(QPushButton, "pushButton_retry").setEnabled(True) errors = any(filter(lambda c: c.is_error(), self._checker_list)) - if errors: + if not errors: self.find(QPushButton, "pushButton_ok").setEnabled(True) self.update_statusbar() @@ -167,5 +168,5 @@ class CheckListWindow(ASubMainWindow, ListedSubWindow): self.end() def accept(self): - print("ok") + self._parent.solver_log(self._solver) self.end() diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py index b7cfa96e..ea23101a 100644 --- a/src/View/MainWindow.py +++ b/src/View/MainWindow.py @@ -28,7 +28,7 @@ from View.InitialConditions.Window import InitialConditionsWindow from View.Stricklers.Window import StricklersWindow from View.Sections.Window import SectionsWindow from View.SolverParameters.Window import SolverParametersWindow -from View.RunSolver.Window import SelectSolverWindow +from View.RunSolver.Window import SelectSolverWindow, SolverLogWindow from View.CheckList.Window import CheckListWindow from Model.Study import Study @@ -391,6 +391,15 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): ) check.show() + def solver_log(self, solver): + sol = SolverLogWindow( + study = self.model, + config = self.conf, + solver = solver, + parent = self + ) + sol.show() + # TODO: Delete me ! ############### # DUMMY STUFF # diff --git a/src/View/RunSolver/Window.py b/src/View/RunSolver/Window.py index 024e0d96..5c5c23c3 100644 --- a/src/View/RunSolver/Window.py +++ b/src/View/RunSolver/Window.py @@ -2,7 +2,7 @@ from tools import trace, timer -from View.ASubWindow import ASubWindow +from View.ASubWindow import ASubWindow, ASubMainWindow from View.ListedSubWindow import ListedSubWindow from PyQt5.QtGui import ( @@ -12,7 +12,7 @@ from PyQt5.QtGui import ( from PyQt5.QtCore import ( Qt, QVariant, QAbstractTableModel, QCoreApplication, QModelIndex, pyqtSlot, - QRect, + QRect, QTimer, ) from PyQt5.QtWidgets import ( @@ -66,3 +66,65 @@ class SelectSolverWindow(ASubWindow, ListedSubWindow): ) super(SelectSolverWindow, self).accept() + + +class SolverLogWindow(ASubMainWindow, ListedSubWindow): + def __init__(self, title="Solver logs", + study=None, config=None, + solver=None, parent=None): + self._title = title + + self._study = study + self._config = config + self._solver = solver + + super(SolverLogWindow, self).__init__( + name=self._title, ui="SolverLog", parent=parent + ) + self.ui.setWindowTitle(self._title) + + self.setup_action() + self.setup_alarm() + self.setup_connections() + + self._alarm.start(500) + + def setup_action(self): + self.find(QAction, "action_start").setEnabled(False) + self.find(QAction, "action_pause").setEnabled(True) + self.find(QAction, "action_stop").setEnabled(True) + + def setup_alarm(self): + self._alarm = QTimer() + + def setup_connections(self): + self.find(QAction, "action_start").triggered.connect(self.start) + self.find(QAction, "action_pause").triggered.connect(self.pause) + self.find(QAction, "action_stop").triggered.connect(self.stop) + + self._alarm.timeout.connect(self.update) + + + def update(self): + print("update") + + def start(self): + print("start") + + self.find(QAction, "action_start").setEnabled(False) + self.find(QAction, "action_pause").setEnabled(True) + self.find(QAction, "action_stop").setEnabled(True) + + def pause(self): + print("pause") + + self.find(QAction, "action_start").setEnabled(True) + self.find(QAction, "action_pause").setEnabled(False) + self.find(QAction, "action_stop").setEnabled(True) + + def stop(self): + print("stop") + + self.find(QAction, "action_start").setEnabled(True) + self.find(QAction, "action_pause").setEnabled(False) + self.find(QAction, "action_stop").setEnabled(False) diff --git a/src/View/ui/SolverLog.ui b/src/View/ui/SolverLog.ui index c236fb51..15e450e4 100644 --- a/src/View/ui/SolverLog.ui +++ b/src/View/ui/SolverLog.ui @@ -16,7 +16,17 @@ <widget class="QWidget" name="centralwidget"> <layout class="QGridLayout" name="gridLayout"> <item row="0" column="0"> - <widget class="QTextEdit" name="textEdit"/> + <widget class="QTextEdit" name="textEdit"> + <property name="documentTitle"> + <string notr="true"/> + </property> + <property name="undoRedoEnabled"> + <bool>false</bool> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> </item> </layout> </widget> -- GitLab