簡體   English   中英

Tkinter標簽未更新

[英]Tkinter Label doesn't update

任何人都可以闡明為什么這不會更新label3嗎?

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

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)

好的-答案是我需要更新我的根窗口! 通過調用window.update(),我解決了這個問題。 窗口聲明為:window = Tk()

只是添加這個,以防其他人偶然發現這個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM