def browse_file(self):
file_path = filedialog.askopenfilename(filetypes=[("All Files", "*.*")])
if file_path:
self.localPath.delete(0, tk.END)
self.localPath.insert(tk.END, file_path)
The function above allows users to select the file from the dialog box, but i wanted to allow the user to select either folder or file.
I want a method that can allow a user to select either file or folder when the function is called
You can check whether the input is
filename
ordirectory
. Here is the sample code: