from tkinter import filedialog from tkinter import * root = Tk() root.withdraw() def select_file(): file_selected = filedialog.askopenfilename( title='Open a file', initialdir='/', filetypes=( ('Text files', '*.txt'), ('All files', '*.*') ) ) print(file_selected) def select_folder(): folder_selected = filedialog.askdirectory() print(folder_selected) if __name__ == '__main__': select_file() select_folder()