3
我有一個小型的Python程序,應該通過運行適當的方法來推動向上按鈕。但不是這樣,它給了我一個令人困惑的錯誤...令人困惑的類型錯誤
from tkinter import *
class App:
def __init__(self, master):
self.left = 0
self.right = 0
widget = Label(master, text='Hello bind world')
widget.config(bg='red')
widget.config(height=5, width=20)
widget.pack(expand=YES, fill=BOTH)
widget.bind('<Up>',self.incSpeed)
widget.focus()
def incSpeed(self):
print("Test")
root = Tk()
app = App(root)
root.mainloop()
和錯誤是:
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python3.2/tkinter/__init__.py", line 1402, in __call__
return self.func(*args)
TypeError: incSpeed() takes exactly 1 positional argument (2 given)
可能是什麼問題?
太好了!非常感謝 :)! – user1496623