Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Commit

Permalink
fix current working directory (last_directory.txt saved at wrong spot…
Browse files Browse the repository at this point in the history
…) bug
  • Loading branch information
schillij95 committed Aug 30, 2024
1 parent a5c8a7a commit 7d3fbe0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions view_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def load_image_parallel(filename):
class Application(tk.Frame):
def __init__(self, master=None):
super().__init__(master)
self.base_dir = os.path.dirname(os.path.abspath(__file__))
self.my_title = "Vesuvius Crackle Viewer"
self.master.title(self.my_title)
if getattr(sys, 'frozen', False):
Expand Down Expand Up @@ -397,12 +398,14 @@ def show_help(self):
tk.messagebox.showinfo("Help", help_message)

def save_last_directory(self):
with open("last_directory.txt", "w") as file:
file_path = os.path.join(self.base_dir, "last_directory.txt")
with open(file_path, "w") as file:
file.write(self.last_directory)

def load_last_directory(self):
file_path = os.path.join(self.base_dir, "last_directory.txt")
try:
with open("last_directory.txt", "r") as file:
with open(file_path, "r") as file:
self.last_directory = file.read().strip()
except FileNotFoundError:
self.last_directory = None
Expand Down

0 comments on commit 7d3fbe0

Please sign in to comment.