2 回答
TA贡献1757条经验 获得超8个赞
command您可以在对象中使用该选项Scale:
from tkinter import *
def sel(val=0): # pass new scale value
#selection = "Value = " + str(var.get())
#label.config(text = selection)
label.config(text = val)
root = Tk()
var = DoubleVar()
scale = Scale( root, variable = var, command=sel) # call sel function on change
scale.pack(anchor=CENTER)
button = Button(root, text="Get Scale Value", command=sel)
button.pack(anchor=CENTER)
label = Label(root)
label.pack()
root.mainloop()
TA贡献1833条经验 获得超4个赞
使用文本变量代替文本参数:
from tkinter import *
root = Tk()
var = DoubleVar()
scale = Scale( root, variable = var )
scale.pack(anchor=CENTER)
label = Label(root, textvariable=var)
label.pack()
root.mainloop()
添加回答
举报