
鼠标拖动和绑定鼠标滚轮移动:
import threading
from tkinter import *
root = Tk()
v = StringVar()
s1 = Scale(root,from_ = ,to = )
s1.pack()
s2 = Scale(root,
from_ = ,#设置最小值
to = ,#设置最大值
orient = HORIZONTAL,#设置横向
# resolution=,#设置步长
# tickinterval = ,#设置刻度
length = ,# 设置像素
variable = v)#绑定变量
s2.pack()
print(v.get())
def wheel(e):
if e.delta > :
s2.set(s2.get()+)
else:
s2.set(s2.get()-) def show():
print(s2.get())
timer = threading.Timer(, show)
timer.start() s2.bind("<MouseWheel>", wheel)
# Button(root,text = '获取位置',command = show).pack()#用command回调函数获取位置
timer = threading.Timer(, show)
timer.start()
mainloop()