0

I've define my function "Torque_Analysis" and an additional function "LoopAnalysis" which takes the "Torque_Analysis" function and loops it for every csv file in directory specified in the "Directory" variable.

Im trying to create a GUI in tkinter where the user will input a file directory such as "C:\Users\example\example" and once the user clicks the button, the script will carry out the "LoopAnalysis" function for every csv file in the user specified directory.

I tested my functions and they work on their own but when i try to execute them in the GUI i get the error "The system cannot find the path specified". But the script won't even generate the GUI where the user would input the file path.

def LoopAnalysis(Directory):
    for filename in os.listdir(Directory):
        if filename.endswith(".csv"):
            Torque_Analysis(os.path.join(Directory, filename))
            plt.figure()
        else: continue


window = tk.Tk()
window.title('Torque Analysis')
window.geometry('300x200+10+20')
label = tk.Label(text="Enter CSV File Directory",)
entry = tk.Entry()
Directory = entry.get()
button = tk.Button(text = 'Click Here to Generate Curves', command=LoopAnalysis(Directory) ,fg = "white", bg = 'black', width = 40, height = 2)


label.pack()
entry.pack()
button.pack()


window.mainloop()
leumasmi
  • 7
  • 2

0 Answers0