I want to click the button to execute the function for uploading files from the device when I define the button before the function, it doesn't work, also it doesn't work if I define the button variable after the function.
so, how to solve it?
ahwal_app = Tk()
ahwal_app.geometry("800x500")
def upload_file():
ahwal_app.filename = filedialog.askopenfilename(initialdir='C:/Users/Manso/Desktop/files/Data Analysis/ahwal',
title='select file',
filetypes=(('excel files', '*.xlsx'),('all files', '*.*')))
upload_btn = Button(ahwal_app, text='Upload', bg='orange', width=10, height=2, borderwidth=2, command=upload_file()).pack()
ahwal_app.mainloop()