From 00b89635f345e549d619eec8a644a6446501e877 Mon Sep 17 00:00:00 2001 From: Theophile Terraz Date: Wed, 22 Apr 2026 11:26:05 +0200 Subject: [PATCH 1/2] add a warning window when opening Adis-TS results from file if wrong directory --- src/View/MainWindow.py | 34 ++++++++++++++++++++++++---------- src/View/Translate.py | 16 ++++++++++++++++ 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py index 793a2b93..f651b3d9 100644 --- a/src/View/MainWindow.py +++ b/src/View/MainWindow.py @@ -951,6 +951,13 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): elif res == QMessageBox.Cancel: return False + def msg_results_warning(self, text="", info=""): + self.message_box( + window_title=self._trad["Warning"], + text=text, + informative_text=info + ) + ######################### # SUB WINDOWS MENU LIST # ######################### @@ -2033,12 +2040,22 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): bin_list = list(filter(lambda s: "bin" in s, dir_list)) if len(bin_list) < 1: - # TODO message + self.msg_results_warning( + info=self._trad["mb_results_not_found"], + text=self._trad["mb_results_bin_not_found"] + ) return path = os.path.normpath(dir_path) solver_name = path.split(os.sep)[-2] solver_results = next(filter(lambda x: x.name == solver_name, - self.conf.solvers)) + self.conf.solvers), None) + if solver_results is None: + self.msg_results_warning( + info=self._trad["mb_results_not_found"], + text=self._trad["mb_results_folder_not_found"] + ) + return + solver_results_adists = solver_results.results( self._study, repertory=dir_path, qlog=None) # self._output) @@ -2050,13 +2067,10 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): results=solver_results_adists, ) else: - dlg = QDialog(self) - dlg.setWindowTitle("AdisTS Results") - layout = QVBoxLayout() - message = QLabel("AdisTS Results not found") - layout.addWidget(message) - dlg.setLayout(layout) - dlg.exec() + self.msg_results_warning( + info=self._trad["mb_results_not_found"], + text=self._trad["mb_results_bin_not_found"] + ) ################# # DOCUMENTATION # @@ -2100,7 +2114,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): def open_doc_user(self): self.open_doc( - "https://gitlab.irstea.fr/theophile.terraz/pamhyr/-/wikis/home" + "https://gitlab.com/pamhyr/pamhyr2/-/wikis/home" ) def open_doc_dev(self, ext="pdf"): diff --git a/src/View/Translate.py b/src/View/Translate.py index 8cddb4c0..43317275 100644 --- a/src/View/Translate.py +++ b/src/View/Translate.py @@ -282,4 +282,20 @@ class MainTranslate(UnitTranslate): self._dict["Cancel"] = _translate("MainWindow", "Cancel") self._dict["Save"] = _translate("MainWindow", "Save") self._dict["Close"] = _translate("MainWindow", "Close") +<<<<<<< HEAD self._dict["Solver"] = _translate("MainWindow", "Solver") +======= + + self._dict["mb_results_not_found"] = _translate( + "MainWindow", "Results can not be loaded" + ) + self._dict["mb_results_folder_not_found"] = _translate( + "MainWindow", "Results folder does not correspond to a Pamhyr2 solver" + ) + self._dict["mb_results_bin_not_found"] = _translate( + "MainWindow", "Results binary files not found" + ) + self._dict["mb_results_total_bin_not_found"] = _translate( + "MainWindow", "total_sediment.bin file not found" + ) +>>>>>>> 3bbc55b (add a warning window when opening Adis-TS results from file if wrong directory) From 260efc17a92a61fc7265b65871008aebd3595056 Mon Sep 17 00:00:00 2001 From: Theophile Terraz Date: Thu, 23 Apr 2026 09:27:29 +0200 Subject: [PATCH 2/2] pep8 + debug --- src/View/Translate.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/View/Translate.py b/src/View/Translate.py index 43317275..82f29b50 100644 --- a/src/View/Translate.py +++ b/src/View/Translate.py @@ -282,15 +282,14 @@ class MainTranslate(UnitTranslate): self._dict["Cancel"] = _translate("MainWindow", "Cancel") self._dict["Save"] = _translate("MainWindow", "Save") self._dict["Close"] = _translate("MainWindow", "Close") -<<<<<<< HEAD self._dict["Solver"] = _translate("MainWindow", "Solver") -======= self._dict["mb_results_not_found"] = _translate( "MainWindow", "Results can not be loaded" ) self._dict["mb_results_folder_not_found"] = _translate( - "MainWindow", "Results folder does not correspond to a Pamhyr2 solver" + "MainWindow", + "Results folder does not correspond to a Pamhyr2 solver name" ) self._dict["mb_results_bin_not_found"] = _translate( "MainWindow", "Results binary files not found" @@ -298,4 +297,3 @@ class MainTranslate(UnitTranslate): self._dict["mb_results_total_bin_not_found"] = _translate( "MainWindow", "total_sediment.bin file not found" ) ->>>>>>> 3bbc55b (add a warning window when opening Adis-TS results from file if wrong directory)