add a warning window when opening Adis-TS results from file if wrong directory

master
Theophile Terraz 2026-04-22 11:26:05 +02:00
parent c0d4aced5e
commit 3bbc55b4be
2 changed files with 36 additions and 9 deletions

View File

@ -860,6 +860,13 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
elif res == QMessageBox.Cancel: elif res == QMessageBox.Cancel:
return False 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 # # SUB WINDOWS MENU LIST #
######################### #########################
@ -1751,12 +1758,22 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
bin_list = list(filter(lambda s: "bin" in s, dir_list)) bin_list = list(filter(lambda s: "bin" in s, dir_list))
if len(bin_list) < 1: 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 return
path = os.path.normpath(dir_path) path = os.path.normpath(dir_path)
solver_name = path.split(os.sep)[-2] solver_name = path.split(os.sep)[-2]
solver_results = next(filter(lambda x: x.name == solver_name, solver_results = next(filter(lambda x: x.name == solver_name,
self.conf.solvers), None) 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( solver_results_adists = solver_results.results(
self._study, self._study,
repertory=dir_path, qlog=None) # self._output) repertory=dir_path, qlog=None) # self._output)
@ -1767,13 +1784,10 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
results=solver_results_adists, results=solver_results_adists,
) )
else: else:
dlg = QDialog(self) self.msg_results_warning(
dlg.setWindowTitle("AdisTS Results") info=self._trad["mb_results_not_found"],
layout = QVBoxLayout() text=self._trad["mb_results_bin_not_found"]
message = QLabel("AdisTS Results not found") )
layout.addWidget(message)
dlg.setLayout(layout)
dlg.exec()
################# #################
# DOCUMENTATION # # DOCUMENTATION #
@ -1817,7 +1831,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
def open_doc_user(self): def open_doc_user(self):
self.open_doc( 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"): def open_doc_dev(self, ext="pdf"):

View File

@ -204,3 +204,16 @@ class MainTranslate(UnitTranslate):
self._dict["Cancel"] = _translate("MainWindow", "Cancel") self._dict["Cancel"] = _translate("MainWindow", "Cancel")
self._dict["Save"] = _translate("MainWindow", "Save") self._dict["Save"] = _translate("MainWindow", "Save")
self._dict["Close"] = _translate("MainWindow", "Close") self._dict["Close"] = _translate("MainWindow", "Close")
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"
)