更新时间:2022-10-31 20:19:30
你们很亲近.
首先,bind
函数需要函数本身作为参数.由于您在末尾有 ()
,因此您正在传递运行该函数的结果,在本例中为 None
.把那些关掉:
First, the bind
function needs the function itself as an argument. Since you have the ()
on the end, you are passing the result of running the function, in this case None
. Just leave those off:
root.bind("<space>",sw.Stop)
其次,bind
调用的函数必须接受一个事件参数.所以你需要像这样定义它:
Second, the function that bind
calls must accept an event argument. So you need to define it like this:
def Stop(self, event=None):