Python Tkinter标签没有';t更新

Python Tkinter标签没有';t更新,python,tkinter,label,Python,Tkinter,Label,有人能解释一下为什么这不会更新label3吗 self.label3Text = StringVar() self.label3Text.set("0/0") self.label3 = Label(textvariable=self.label3Text) self.label3.pack() 好的-所以答案是我需要更新我的根窗口!通过调用window.update(),我解决了这个问题。其中window被声明为:window=Tk() 如果有人无意中发现这个问题,就加上这个 for ro

有人能解释一下为什么这不会更新label3吗

self.label3Text = StringVar()
self.label3Text.set("0/0")
self.label3 = Label(textvariable=self.label3Text)
self.label3.pack()


好的-所以答案是我需要更新我的根窗口!通过调用window.update(),我解决了这个问题。其中window被声明为:window=Tk()

如果有人无意中发现这个问题,就加上这个

for root,dirs,filenames in os.walk(self.path):
    #iterate through the files
    num_files = len(filenames)
    i = 0
    for f in filenames:
        #if the file is a text file
        if ".txt" in f:
            #define the path of this new file as the datalog folder plus the filename
            file_path = os.path.join(self.path,f)
            #write the correct data to the csv file for this file
            self.addRows(f,file_path)
            i = i + 1
            out = str(i) + "/" + str(num_files) + " files processed"
            self.label3Text.set(out)