Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI: Remember the path to the input files #178

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions hypnotoad/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ def __init__(self):
super().__init__(None)
self.setupUi(self)

# Used in file dialogs
self._current_dir = "."

try:
self.menu_File.setToolTipsVisible(True)
self.menu_Mesh.setToolTipsVisible(True)
Expand Down Expand Up @@ -452,7 +455,7 @@ def select_options_file(self):
"""Choose a Hypnotoad options file to load"""

filename, _ = QFileDialog.getOpenFileName(
self, "Open options file", ".", filter=YAML_FILTER
self, "Open options file", self._current_dir, filter=YAML_FILTER
)

if (filename is None) or (filename == ""):
Expand All @@ -461,6 +464,9 @@ def select_options_file(self):
self.write("Could not find " + filename)
return

# Record the directory so user doesn't have to navigate again
self._current_dir = os.path.dirname(filename)

self.options_file_line_edit.setText(filename)
self.filename = filename
self.read_options()
Expand Down Expand Up @@ -506,7 +512,9 @@ def read_options(self):
def select_geqdsk_file(self):
"""Choose a "geqdsk" equilibrium file to open"""

filename, _ = QFileDialog.getOpenFileName(self, "Open geqdsk file", ".")
filename, _ = QFileDialog.getOpenFileName(
self, "Open geqdsk file", self._current_dir
)

if (filename is None) or (filename == ""):
return # Cancelled
Expand All @@ -517,6 +525,9 @@ def select_geqdsk_file(self):
)
return

# Record the directory so user doesn't have to navigate again
self._current_dir = os.path.dirname(filename)

self.geqdsk_file_line_edit.setText(filename)
self.geqdsk_file_line_edit.setStyleSheet("")

Expand Down Expand Up @@ -643,7 +654,7 @@ def write_grid(self):
filename, _ = QFileDialog.getSaveFileName(
self,
"Save grid to file",
self.gui_options["grid_file"],
os.path.join(self._current_dir, self.gui_options["grid_file"]),
filter=NETCDF_FILTER,
)

Expand Down
Loading