Closing windows of tkinter Closing windows of tkinter tkinter tkinter

Closing windows of tkinter


If all you want to do is change the text of the label, then use the config method on the label. The App, Appo, and QQQ classes, as well as the for loop can be combined into a single class as:

import Tkinter as tk #Python 2#import tkinter as tk #Python 3import threadingimport timeclass App(threading.Thread):    def __init__(self):        threading.Thread.__init__(self)        self.root = tk.Tk()        self.start()    def callback(self):        self.root.quit()    def run(self):        self.root.protocol("WM_DELETE_WINDOW", self.callback)        label = tk.Label(self.root, text="Initial Text") # You can use text=""        label.pack()        for i in range(100000):            time.sleep(0.5)            print (i)            if i == 1:                label.config(text="Start Initialization")                time.sleep(1)                label.config(text="")            if i == 10:                label.config(text="Initialization ended")        #self.root.mainloop()app = App()app.root.mainloop()

It might be better to use the after method of tkinter for time delays instead of time.sleep()