Open and Read text files in Tkinter Python Open and Read text files in Tkinter Python tkinter tkinter

Open and Read text files in Tkinter Python


This is actually rather simple.

All you need to do is open the file and read the information into the text attribute of the widget.

This can be done as below:

from tkinter import *root = Tk()with open("file.txt", "r") as f:    Label(root, text=f.read()).pack()root.mainloop()