pythontkinter进度条
时间: 2023-12-23 22:28:39 浏览: 113
python 进度条
3星 · 编辑精心推荐
以下是两种使用Python tkinter库创建进度条的例子:
1. 使用确定性进度条:
```python
import time
import tkinter
import tkinter.ttk
def show():
for i in range(100):
progressbarOne['value'] = i + 1
root.update()
time.sleep(0.05)
root = tkinter.Tk()
root.geometry('150x120')
progressbarOne = tkinter.ttk.Progressbar(root)
progressbarOne.pack(pady=20)
progressbarOne['maximum'] = 100
progressbarOne['value'] = 0
button = tkinter.Button(root, text='Running', command=show)
button.pack(pady=5)
root.mainloop()
```
2. 使用不确定性进度条:
```python
import tkinter
import tkinter.ttk
root = tkinter.Tk()
root.geometry('150x120')
progressbarOne = tkinter.ttk.Progressbar(root, length=200, mode='indeterminate', orient=tkinter.HORIZONTAL)
progressbarOne.pack(pady=20)
root.mainloop()
```
阅读全文