I've created a GUI that allows the user to select a folder (Windows environment) to save files to when clicking a button and then that path is put into an entry widget. I've noticed that the last folder selected is always the starting folder for the dialog box. My question is how does askdirectory know what the last folder was? I want to use that directory for my initial local_path entry widget. Right now I'm setting that value as the documents folder but I would prefer to use the last selected folder. See code below. Since all variables are gone when the script finishes it must be something python is pulling from windows itself. The initial directory in the dialog box is not the current working directory of the python script. I'm using Python 3. Thanks for any help.
local_path = tk.StringVar()
self.local_path.set('c:/Users/' + user_name.get() + '/Documents/')
self.local_path_entry = ttk.Entry(mainframe, textvariable=self.local_path, font=('', 12))
self.browse_button = tk.Button(mainframe, text="Browse", command=self.browse)
def browse(self):
self.local_path.set(filedialog.askdirectory())