mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Mainwindow: Add action to open results from a file.
This commit is contained in:
1 parent
852a3f58ff
commit
73475220e9
2 files changed
+45
-1
No files matched your search
+36
-1
@@ -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 #
|
||||
#################
|
||||
|
||||
Reference in new issue
Block a user