diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py
index 793a044e..41a25c07 100644
--- a/src/View/MainWindow.py
+++ b/src/View/MainWindow.py
@@ -82,7 +82,7 @@ no_model_action = [
model_action = [
"action_menu_close", "action_menu_edit", "action_menu_save",
"action_menu_save_as", "action_toolBar_close", "action_toolBar_save",
- "action_menu_numerical_parameter",
+ "action_menu_numerical_parameter", "action_open_results_from_file",
]
other_model_action = [
@@ -207,6 +207,7 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
self.open_reach_sediment_layers,
"action_menu_close": self.close_model,
"action_menu_results_last": self.open_last_results,
+ "action_open_results_from_file": self.open_results_from_file,
# Help
"action_menu_pamhyr_users_pdf":
lambda: self.open_doc_user(ext="pdf"),
@@ -838,6 +839,14 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
self._solver_workdir(solver)
)
+ # Open from file
+ if type(results) is str:
+ logger.info(f"Open results from {os.path.dirname(results)}")
+ results = solver.results(
+ self._study,
+ os.path.dirname(results),
+ )
+
# No results available
if results is None:
return
@@ -878,6 +887,32 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
self.open_solver_results(self._last_solver, self._last_results)
+ def open_results_from_file(self):
+ if self._study is None:
+ return
+
+ dialog = QFileDialog(self)
+ dialog.setFileMode(QFileDialog.FileMode.ExistingFile)
+ dialog.setDefaultSuffix(".BIN")
+ # dialog.setFilter(dialog.filter() | QtCore.QDir.Hidden)
+ dialog.setNameFilters(['Mage (*.BIN)'])
+
+ if self._last_solver is None:
+ dialog.setDirectory(
+ os.path.dirname(self._study.filename)
+ )
+ else:
+ dialog.setDirectory(
+ self._solver_workdir(self._last_solver)
+ )
+
+ if dialog.exec_():
+ file_name = dialog.selectedFiles()
+ self.open_solver_results(
+ self._last_solver,
+ results=file_name[0]
+ )
+
#################
# DOCUMENTATION #
#################
diff --git a/src/View/ui/MainWindow.ui b/src/View/ui/MainWindow.ui
index bf73c3d3..ecb069cc 100644
--- a/src/View/ui/MainWindow.ui
+++ b/src/View/ui/MainWindow.ui
@@ -139,6 +139,7 @@
&Results
+