我如何获得tkinter标度的值并将其转换为十六进制字符串

时间:2019-07-25 14:01:55

标签: python tkinter

本质上,我想获取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'

有人可以告诉我我哪里出问题了吗?

0 个答案:

没有答案