在Python中-如何使进度条动态?(如果选择了“选项”菜单,则会发生更改) 例如,如果我在pl1(拾取列表)中选择一个选项,进度条将发生变化(比如20%的进度)
到目前为止,我试过:
from tkinter import *
from tkinter.ttk import Progressbar
pets= {'Cat', 'Dog', 'Fish'}
def __init__(self):
root =Tk()
root.title('window')
root.geometry('1300x690')
root.resizable(False, False)
progress = Progressbar(root, orient=HORIZONTAL, length=300, mode='determinate')
progress.place(x=500, y=15)
var1 = StringVar(root)
pl1 = OptionMenu(root, var1, *self.pets)
pl1.config(width=20, bg="GREEN", fg="white")
pl1.place(x=470, y=230)
#Here I want to add 20% progress to the bar if var1 has been selected (no matter what is the
value).
root.mainloop()
谢谢
试着这样做:
我基本上跟踪
var
的值,当它改变时callback
被调用。当调用callback
时,它会传入一些我们可以忽略的参数相关问题 更多 >
编程相关推荐