Keyboard Shortcut “Takes 1 positional argument but 2 were given”

丶灬走出姿态 提交于 2019-11-29 08:52:51

That is easy - whatever the mechanism that binds the shortcut does, it is passing an extra parameter to your reset method.

Since you don't care what it is at all, just declare your method to accept an extra optional parameter, and you should be good:

...
def reset(self, event=None):
    self._game.get_default_score()
    ...

So, searching for "bind_all" we find out your code actually uses tkinter, and what tkinter passe along to your method is the "event" - an object with information on what key whas actually pressed and such - http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!