Only one file type to be accepted Only one file type to be accepted tkinter tkinter

Only one file type to be accepted


filetypes needs to be a tuple of tuples. For example:

from tkinter import filedialog as fdfilename = fd.askopenfilename(title = "Select file",filetypes = (("CSV Files","*.csv"),))

But I suggest you make it all neat and in one window. For example, same input as yours but tidier:

from tkinter import *from tkinter import filedialog as fddef get_file_name(file_entry):    file_name = fd.askopenfilename(title = "Select file",filetypes = (("CSV Files","*.csv"),))    file_entry.delete(0,END)    file_entry.insert(0,file_name)def run_and_close(event=None):    ######################################    ## EXECUTE OR CALL OTHER PYTHON FILE##    ######################################    close()def close(event=None):    master.withdraw() # if you want to bring it back    sys.exit() # if you want to exit the entire thingmaster = Tk()master.title("This is my Interface")entry_csv=Entry(master, text="", width=50)entry_csv.grid(row=0, column=1, sticky=W, padx=5)Label(master, text="Input CSV").grid(row=0, column=0 ,sticky=W)Button(master, text="Browse...", width=10, command=lambda:get_file_name(entry_csv)).grid(row=0, column=2, sticky=W)Button(master, text="Ok",     command=run_and_close, width=10).grid(row=3, column=1, sticky=E, padx=5)Button(master, text="Cancel", command=close, width=10).grid(row=3, column=2, sticky=W)master.bind('<Return>', run_and_close)master.bind('<Escape>', close)mainloop()