Select files and folders with Tkinter's filedialog

Advertisements I want to select files and folders with filedialog in Tkinter(Python). I try using askdirectory and askopenfilenames. But I can’t find a special dialog in documentation. https://docs.python.org/3/library/dialog.html This is my sample code: root = tk.Tk() root.withdraw() # one way files_and_directories = filedialog.askopenfilenames(parent=root, title="Select files and folders", multiple=True) # another way files_and_directories = filedialog.askdirectory(parent=root, title=’Select… Read More Select files and folders with Tkinter's filedialog

I don't know how it is an unmatched )

Advertisements from tkinter import * from tkinter import filedialog def openFile(): filepath = filedialog.askopenfile() file = open(filepath), ‘r’) print(file.read()) file.close() window = Tk() button = Button(text="Open",command=openFile) button.pack() window.mainloop() C:\Users\Hp\PycharmProjects\pythonProject\venv\Scripts\python.exe "C:\Users\Hp\PycharmProjects\pythonProject\open a file.py" File "C:\Users\Hp\PycharmProjects\pythonProject\open a file.py", line 7 file = open(filepath), ‘r’) ^ SyntaxError: unmatched ‘)’ Process finished with exit code 1 >Solution : From… Read More I don't know how it is an unmatched )