小编Alt*_*zeM的帖子

如何循环更新进度条?

循环更新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)

python user-interface tkinter python-2.7

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×1

python-2.7 ×1

tkinter ×1

user-interface ×1