循环更新Tkinter进度条的简便方法是什么?
我需要一个没有太多混乱的解决方案,所以我可以轻松地在脚本中实现它,因为它对我来说已经很复杂了。
假设代码是:
from Tkinter import *
import ttk
root = Tk()
root.geometry('{}x{}'.format(400, 100))
theLabel = Label(root, text="Sample text to show")
theLabel.pack()
status = Label(root, text="Status bar:", bd=1, relief=SUNKEN, anchor=W)
status.pack(side=BOTTOM, fill=X)
root.mainloop()
def loop_function():
k = 1
while k<30:
### some work to be done
k = k + 1
### here should be progress bar update on the end of the loop
### "Progress: current value of k =" + str(k)
# Begining of a program
loop_function()
Run Code Online (Sandbox Code Playgroud)