mirror of https://gitlab.com/pamhyr/pamhyr2
keyword for file_dialog mode selection
parent
1bc9b9fc86
commit
47ac8e8bef
|
|
@ -74,17 +74,17 @@ class ConfigureSolverWindow(PamhyrDialog):
|
|||
# File button
|
||||
buttons = {
|
||||
"pushButton_input": (lambda: self.file_dialog(
|
||||
select_file=True,
|
||||
select_file="ExistingFile",
|
||||
callback=lambda f: self.set_line_edit_text(
|
||||
"lineEdit_input", f[0])
|
||||
)),
|
||||
"pushButton_solver": (lambda: self.file_dialog(
|
||||
select_file=True,
|
||||
select_file="ExistingFile",
|
||||
callback=lambda f: self.set_line_edit_text(
|
||||
"lineEdit_solver", f[0])
|
||||
)),
|
||||
"pushButton_output": (lambda: self.file_dialog(
|
||||
select_file=True,
|
||||
select_file="ExistingFile",
|
||||
callback=lambda f: self.set_line_edit_text(
|
||||
"lineEdit_output", f[0])
|
||||
)),
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ class ConfigureWindow(PamhyrDialog):
|
|||
"pushButton_stricklers_sort": self.sort_stricklers,
|
||||
# Others
|
||||
# "pushButton_backup_path": lambda: self.file_dialog(
|
||||
# select_file=False,
|
||||
# select_file="Directory",
|
||||
# callback=lambda f: self.set_line_edit_text(
|
||||
# "lineEdit_backup_path", f[0]
|
||||
# )
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ class InitialConditionsWindow(PamhyrWindow):
|
|||
workdir = os.path.dirname(self._study.filename)
|
||||
|
||||
return self.file_dialog(
|
||||
select_file=True,
|
||||
select_file="ExistingFile",
|
||||
callback=lambda d: self._import_from_file(d[0]),
|
||||
directory=workdir,
|
||||
default_suffix=".BIN",
|
||||
|
|
|
|||
|
|
@ -597,6 +597,7 @@ class ResultsWindow(PamhyrWindow):
|
|||
f"{x} -> {','.join(y)}"
|
||||
)
|
||||
self.file_dialog(
|
||||
select_file="AnyFile",
|
||||
callback=lambda f: self.export_to(f[0], x, y),
|
||||
default_suffix=".csv",
|
||||
file_filter=["CSV (*.csv)"],
|
||||
|
|
@ -651,7 +652,7 @@ class ResultsWindow(PamhyrWindow):
|
|||
|
||||
def export_current(self):
|
||||
self.file_dialog(
|
||||
select_file=False,
|
||||
select_file="Directory",
|
||||
callback=lambda d: self.export_current_to(d[0])
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ class WindowToolKit(object):
|
|||
|
||||
return header, values
|
||||
|
||||
def file_dialog(self, select_file=None,
|
||||
def file_dialog(self, select_file="ExistingFile",
|
||||
callback=lambda x: None,
|
||||
directory=None,
|
||||
default_suffix=None,
|
||||
|
|
@ -107,11 +107,10 @@ class WindowToolKit(object):
|
|||
|
||||
dialog = QFileDialog(self, options=options)
|
||||
|
||||
if select_file is not None:
|
||||
if select_file:
|
||||
mode = QFileDialog.FileMode.ExistingFile
|
||||
else:
|
||||
mode = QFileDialog.FileMode.Directory
|
||||
if select_file == "Existing_file":
|
||||
mode = QFileDialog.FileMode.ExistingFile
|
||||
elif select_file == "Directory":
|
||||
mode = QFileDialog.FileMode.Directory
|
||||
else:
|
||||
mode = QFileDialog.FileMode.AnyFile
|
||||
|
||||
|
|
@ -119,7 +118,7 @@ class WindowToolKit(object):
|
|||
if directory is not None:
|
||||
dialog.setDirectory(directory)
|
||||
|
||||
if select_file is not False:
|
||||
if select_file != "Directory":
|
||||
if default_suffix is not None:
|
||||
dialog.setDefaultSuffix(default_suffix)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue