mirror of https://gitlab.com/pamhyr/pamhyr2
Results: Delete ReadingResultsDialog (switch to WaitingDialog).
parent
4222503961
commit
c4e1a4c485
|
|
@ -60,7 +60,7 @@ from View.InitialConditions.PlotDischarge import PlotDischarge
|
||||||
from View.InitialConditions.translate import ICTranslate
|
from View.InitialConditions.translate import ICTranslate
|
||||||
from View.InitialConditions.DialogHeight import HeightDialog
|
from View.InitialConditions.DialogHeight import HeightDialog
|
||||||
from View.InitialConditions.DialogDischarge import DischargeDialog
|
from View.InitialConditions.DialogDischarge import DischargeDialog
|
||||||
from View.Results.ReadingResultsDialog import ReadingResultsDialog
|
from View.WaitingDialog import WaitingDialog
|
||||||
|
|
||||||
from Solver.Mage import Mage8
|
from Solver.Mage import Mage8
|
||||||
|
|
||||||
|
|
@ -267,8 +267,9 @@ class InitialConditionsWindow(PamhyrWindow):
|
||||||
name=name
|
name=name
|
||||||
)
|
)
|
||||||
|
|
||||||
dlg = ReadingResultsDialog(
|
dlg = WaitingDialog(
|
||||||
reading_fn=reading,
|
reading_fn=reading,
|
||||||
|
title="waiting_result",
|
||||||
parent=self
|
parent=self
|
||||||
)
|
)
|
||||||
dlg.exec_()
|
dlg.exec_()
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,6 @@ from View.SolverParameters.Window import SolverParametersWindow
|
||||||
from View.RunSolver.Window import SelectSolverWindow, SolverLogWindow
|
from View.RunSolver.Window import SelectSolverWindow, SolverLogWindow
|
||||||
from View.CheckList.Window import CheckListWindow
|
from View.CheckList.Window import CheckListWindow
|
||||||
from View.Results.Window import ResultsWindow
|
from View.Results.Window import ResultsWindow
|
||||||
from View.Results.ReadingResultsDialog import ReadingResultsDialog
|
|
||||||
from View.Debug.Window import ReplWindow
|
from View.Debug.Window import ReplWindow
|
||||||
|
|
||||||
# Optional internal display of documentation for make the application
|
# Optional internal display of documentation for make the application
|
||||||
|
|
|
||||||
|
|
@ -1,117 +0,0 @@
|
||||||
# ReadingResultsDialog.py -- Pamhyr
|
|
||||||
# Copyright (C) 2023-2024 INRAE
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
import logging
|
|
||||||
|
|
||||||
from tools import logger_exception
|
|
||||||
|
|
||||||
from View.Tools.PamhyrWindow import PamhyrDialog
|
|
||||||
from View.Results.translate import ResultsTranslate
|
|
||||||
|
|
||||||
from PyQt5.QtGui import (
|
|
||||||
QKeySequence,
|
|
||||||
)
|
|
||||||
|
|
||||||
from PyQt5.QtCore import (
|
|
||||||
Qt, QVariant, QAbstractTableModel, QTimer,
|
|
||||||
QObject, pyqtSlot, pyqtSignal, QThread,
|
|
||||||
)
|
|
||||||
|
|
||||||
from PyQt5.QtWidgets import (
|
|
||||||
QLabel,
|
|
||||||
)
|
|
||||||
|
|
||||||
logger = logging.getLogger()
|
|
||||||
|
|
||||||
|
|
||||||
class Worker(QObject):
|
|
||||||
signalStatus = pyqtSignal(str)
|
|
||||||
|
|
||||||
def __init__(self, reading_fn, parent=None):
|
|
||||||
super(self.__class__, self).__init__(parent)
|
|
||||||
|
|
||||||
self._reading_fn = reading_fn
|
|
||||||
|
|
||||||
def process(self):
|
|
||||||
self._reading_fn()
|
|
||||||
self.signalStatus.emit('end')
|
|
||||||
|
|
||||||
|
|
||||||
class ReadingResultsDialog(PamhyrDialog):
|
|
||||||
_pamhyr_ui = "DialogReadingResults"
|
|
||||||
_pamhyr_name = "Reading results"
|
|
||||||
|
|
||||||
_spin = ["-", "\\", "|", "/"]
|
|
||||||
|
|
||||||
def __init__(self, reading_fn, parent=None):
|
|
||||||
trad = ResultsTranslate()
|
|
||||||
super(ReadingResultsDialog, self).__init__(
|
|
||||||
title=trad[self._pamhyr_name],
|
|
||||||
trad=trad,
|
|
||||||
options=[],
|
|
||||||
parent=parent
|
|
||||||
)
|
|
||||||
|
|
||||||
self._reading_fn = reading_fn
|
|
||||||
|
|
||||||
self._init_default_values()
|
|
||||||
|
|
||||||
self.setup_timer()
|
|
||||||
self.setup_worker()
|
|
||||||
|
|
||||||
self._timer.start(150)
|
|
||||||
self._worker_thread.start()
|
|
||||||
|
|
||||||
def _init_default_values(self):
|
|
||||||
self._spinner_step = 0
|
|
||||||
|
|
||||||
self.set_label_text("label_spinner", self._spin[0])
|
|
||||||
|
|
||||||
def setup_worker(self):
|
|
||||||
self._worker = Worker(self._reading_fn)
|
|
||||||
self._worker_thread = QThread(parent=self)
|
|
||||||
self._worker.moveToThread(self._worker_thread)
|
|
||||||
|
|
||||||
self._worker.signalStatus.connect(self.close)
|
|
||||||
self._worker_thread.started.connect(self._worker.process)
|
|
||||||
|
|
||||||
def setup_timer(self):
|
|
||||||
self._timer = QTimer(self)
|
|
||||||
self._timer.timeout.connect(self.update_spinner)
|
|
||||||
|
|
||||||
def update_spinner(self):
|
|
||||||
self._spinner_step += 1
|
|
||||||
self._spinner_step %= len(self._spin)
|
|
||||||
|
|
||||||
self.set_label_text(
|
|
||||||
"label_spinner",
|
|
||||||
self._spin[self._spinner_step]
|
|
||||||
)
|
|
||||||
|
|
||||||
def end_worker(self):
|
|
||||||
self._worker_thread.terminate()
|
|
||||||
self._worker_thread.wait()
|
|
||||||
|
|
||||||
def close(self):
|
|
||||||
try:
|
|
||||||
self._timer.stop()
|
|
||||||
self.end_worker()
|
|
||||||
except Exception as e:
|
|
||||||
logger_exception(e)
|
|
||||||
|
|
||||||
super().close()
|
|
||||||
|
|
@ -44,7 +44,7 @@ from PyQt5.QtWidgets import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from View.RunSolver.Log.Window import SolverLogFileWindow
|
from View.RunSolver.Log.Window import SolverLogFileWindow
|
||||||
from View.Results.ReadingResultsDialog import ReadingResultsDialog
|
from View.WaitingDialog import WaitingDialog
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from signal import SIGTERM, SIGSTOP, SIGCONT
|
from signal import SIGTERM, SIGSTOP, SIGCONT
|
||||||
|
|
@ -297,7 +297,11 @@ class SolverLogWindow(PamhyrWindow):
|
||||||
logger.error(f"Failed to open results")
|
logger.error(f"Failed to open results")
|
||||||
logger_exception(e)
|
logger_exception(e)
|
||||||
|
|
||||||
dlg = ReadingResultsDialog(reading_fn=reading_fn, parent=self)
|
dlg = WaitingDialog(
|
||||||
|
reading_fn=reading_fn,
|
||||||
|
title="waiting_result",
|
||||||
|
parent=self
|
||||||
|
)
|
||||||
dlg.exec_()
|
dlg.exec_()
|
||||||
|
|
||||||
def _update_logs_all(self):
|
def _update_logs_all(self):
|
||||||
|
|
@ -384,7 +388,11 @@ class SolverLogWindow(PamhyrWindow):
|
||||||
self._study, self._workdir, qlog=self._output
|
self._study, self._workdir, qlog=self._output
|
||||||
)
|
)
|
||||||
|
|
||||||
dlg = ReadingResultsDialog(reading_fn=reading_fn, parent=self)
|
dlg = WaitingDialog(
|
||||||
|
reading_fn=reading_fn,
|
||||||
|
title="waiting_result",
|
||||||
|
parent=self
|
||||||
|
)
|
||||||
dlg.exec_()
|
dlg.exec_()
|
||||||
|
|
||||||
self._parent.set_results(self._solver, self._results)
|
self._parent.set_results(self._solver, self._results)
|
||||||
|
|
|
||||||
|
|
@ -1,77 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>Dialog</class>
|
|
||||||
<widget class="QDialog" name="Dialog">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>205</width>
|
|
||||||
<height>42</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Dialog</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Read results:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_spinner">
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<family>Monospace</family>
|
|
||||||
<pointsize>12</pointsize>
|
|
||||||
<weight>50</weight>
|
|
||||||
<bold>false</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>.</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
Loading…
Reference in New Issue