from tkinter import *
root=Tk()
def function1():
L=Label(root,text="Loading...").pack()
for i in range(10000):
L1=Label(root,text=str(i**2)).pack()
function1()
This is a simplified version of my code. How to get the function to display the label as "Loading..." calculate the values for a few seconds then at last show up the labels? Usually the program waits till the whole code is done and shows loading.