open file and read lines tkinter askopenfile code example
Example 1: askopenfilename
filename2 = filedialog.askopenfilename(title = "Select file",filetypes = (("Excel files", ".xlsx .xls"),))
Example 2: python tkinter askopenfile
file = askopenfile(mode ='r', filetypes =[('Python Files', '*.py'), ('Text Files', '*.txt')])
if file is not None:
content = file.read()
print(content)
file.close()