我不知道为什么我不能得到刻度的值,为什么我得到这个错误信息。有人能帮我吗?在
from tkinter import *
Op = Tk()
def sb():
print (Voboll1)
Oboll=Label(Op, text='BOLL')
Oboll.grid(row=1,column=0)
Voboll1 = StringVar()
# Création d'un widget Scale
Oboll1= Scale(Op,from_=-0.2,to=0.2,resolution=0.01,orient=HORIZONTAL,\
length=235,width=20,tickinterval=20,variable=Voboll1,command=sb)
Oboll1.grid(row=1,column=1)
Op.mainloop()
错误消息:
TypeError: sb() takes no arguments (1 given)
根据文件:
src:http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/scale.html
因此,
command
参数会自动将一个值传递给您调用的过程,在本例中是sb()
。但是,您的sb
定义采用了no参数,因此会发生冲突和错误。在因为您似乎希望使用
Voboll1
值作为刻度,请将Voboll1
作为sb
过程的参数。在应该可以清除错误。在
相关问题 更多 >
编程相关推荐