I want to understand more about the bind method
I can't figure out, why that code doesn't work, (I reduce my problem to this, to help me understand the reason), thank you so much for your time
from kivy.app import App
from kivy.uix.gridlayout import GridLayout
class Game(GridLayout):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.a = 0
self.bind(a=self.f)
def f(self, *args):
print("ok")
class TestApp(App):
def build(self):
self.game = Game()
return self.game
if __name__ == "__main__":
TestApp().run()
Traceback (most recent call last):
File "test2.py", line 23, in <module>
TestApp().run()
File "C:\Users\Legion\AppData\Local\Programs\Python\Python37-32\lib\site-packages\kivy\app.py", line 829, in run
root = self.build()
File "test2.py", line 18, in build
self.game = Game()
File "test2.py", line 10, in __init__
self.bind(a=self.f)
File "kivy\_event.pyx", line 427, in kivy._event.EventDispatcher.bind
KeyError: 'a'