diff --git a/hypnotoad/gui/gui.py b/hypnotoad/gui/gui.py index dca0646a..96baee09 100644 --- a/hypnotoad/gui/gui.py +++ b/hypnotoad/gui/gui.py @@ -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) @@ -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 == ""): @@ -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() @@ -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 @@ -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("") @@ -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, )