Even when run in a seperate thread my UI hangs while a large file is being loaded into a Text widget. Is it just because the application is under heavy load or is there a way I can keep the UI functional while this is happening. Im loading several text files in different widgets so the hang up is longer than desired.
from tkinter import *
import threading
i = 'large/text/file/400,000+lines'
root = Tk()
txt = Text(root)
txt.grid()
def loadfile():
with open(i, 'r') as f:
a = f.readlines()
txt.insert('end', ' '.join(a))
#for line in a:
# txt.insert('end', line)
def threadstarter():
startit = threading.Thread(target=loadfile())
startit.start()
btn = Button(root, text= 'start', command=lambda: threadstarter())
btn.grid()
root.mainloop()
Tested on several machines with plenty of resources.