I found this piece of code here on Stack Overflow and I integrated it into my gui. I would ask a question if I could, but I don't have the reps for that.
This is the code I am borrowing.
def selectPath():
path_ = askdirectory()
path.set(path_)
def create_file():
print("folder_name: ", folder.get())
print("path_name: ", path.get())
dirs = os.path.join(path.get(), folder.get())
if not os.path.exists(dirs):
os.makedirs(dirs)
tkinter.messagebox.showinfo('Tips:','Folder name created successfully!')
else:
tkinter.messagebox.showerror('Tips','The folder name exists, please change it')
What I would like to do is reference the path in my py files that are executed in the gui. I make a number of intermediate files. It would be nice if they could save to the new folder. For example, how could I change this to be variable and go to the created folder and instead of the location noted below?
df_new.to_csv(r'C:\Users\XXX\File.txt',sep='\t',index=False)
Can I import a portion of the tkinter gui properties/folder name and path? And then insert that into the py output files? Thanks!