python進度條Progressbar 例項

2022-08-14 02:57:14 字數 1244 閱讀 7266

from tkinter import *

from tkinter import ttk

import time

def manu_increment(*args):

for i in range(100):

p1["value"] = i+1

root.update()

time.sleep(0.1)

def auto_increment(*args):

global flag,value

flag = not flag

if flag:

btn2["text"] = "暫停動畫"

p2.start(10)

else:

btn2["text"] = "開始動畫"

value = p2["value"]

p2.stop()

p2["value"] = value

root = tk()

root.title("progressbar元件")

# 定量進度條

p1 = ttk.progressbar(root, length=200, mode="determinate", orient=horizontal)

p1.grid(row=1,column=1)

p1["maximum"] = 100

p1["value"] = 0

# 通過指定變數,改變進度條位置

# n = intvar()

# p1["variable"] = n

# 通過指定步長,改變進度條位置

# p1.step(2)

btn = ttk.button(root,text="開始動畫",command=manu_increment)

btn.grid(row=1,column=0)

# 非定量進度條

flag = false # 標誌位

value = 0 # 進度條位置

p2 = ttk.progressbar(root, length=200, mode="indeterminate", orient=horizontal)

p2.grid(row=2,column=1)

btn2 = ttk.button(root,text="自動動畫",command=auto_increment)

btn2.grid(row=2,column=0)

root.mainloop()

Python 模擬進度條

usr bin python coding utf 8 import time import sys print sys.argv 命令列引數list,第乙個元素是程式本身路徑 print sys.exit goodbye 退出程式 sys.version 獲取python 的版本資訊 sys.ma...

python 列印進度條

列印進度條 coding utf 8 import sys import time def progress percent,width 50 進度條列印 if percent 100 percent 100 show str ds width int width percent 100 字串拼接的...

python 文字進度條

textprobarv.py import time scale 50 print 執行開始 center scale 2,start time.perf counter for i in range scale 1 a i b scale i c i scale 100 dur time.perf...