本质上,我想获取tkinter刻度的整数值,并将其转换为十六进制字符串。这是我到目前为止的内容:
MainPage = Tk()
def CommandBuilder():
#forward RPM
return print(hex(RPM.get()))
RPM = IntVar
Go = Button(MainPage, text = "Go", height=2, width=10, command=CommandBuilder)
Go.place(x=0,y=0)
Speed = Scale(MainPage, from_=0, to=10000, orient=HORIZONTAL, resolution=100, length=200, label="Speed (RPM)", variable = RPM)
Speed.place(x=100,y=0)
MainPage.mainloop
但是我得到了错误
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\tkinter\__init__.py", line 1702, in __call__
return self.func(*args)
File "C:\Users\tsearight\Documents\Tkinter test.py", line 16, in CommandBuilder
return print(hex(RPM.get()))
TypeError: get() missing 1 required positional argument: 'self'
有人可以告诉我我哪里出问题了吗?