title: Understanding Kivy properities and binding methods
body: <p>I am having problems understanding the usage of custom Properities and ways of binding methods to events.
  Here's my code:</p>
  
  <pre><code>from kivy.app import App
  from kivy.lang import Builder
  
  from kivy.uix.boxlayout import BoxLayout
  from kivy.uix.label import Label
  from kivy.uix.button import Button
  from kivy.properties import StringProperty
  
  kivy_lang = '''
  &lt;MainWidget&gt;:
      on_my_property: my_label.text = 'from button bind method via StringProperty' + my_property
  
      Label:
          id: my_label
          text: root.my_property
      Button:
          id: my_button
          text: 'intro button'
  
  '''
  
  
  class MainWidget(BoxLayout):
      # bind some properties
      my_property = StringProperty('0')
  
      def __init__(self, **kwargs):
          super(MainWidget, self).__init__(**kwargs)
      #     if needed to do sth on widget construction
          self.ids.my_button.bind(on_press=self.my_method)
  
  
      def my_method(self,*args,**kwargs):
          self.my_property = str(int(self.my_property)+1)
          self.ids.my_button.text = 'new'
  
  
  class MyApp(App):
      def build(self):
          Builder.load_string(kivy_lang)
          return MainWidget()
  
  if __name__ == '__main__':
      MyApp().run()
  </code></pre>
  
  <p>When I run it it renders OK, but when I click a button, as a result I get
  NameError: name 'my_property' is not defined</p>
  
  <p>I tried binding method for Button in kv lang with (and removing whole '<strong>init</strong>()' on python side):</p>
  
  <pre><code>on_press: root.my_method
  </code></pre>
  
  <p>and then when I press button the app doesn't crash but nothing happens</p>
  
  <p>Can someone explain me how to adjust this code to work?
  I understand the code is a little 'mixed techniques' but I did it that way to get to know different approaches, so I would appreciate if You don't turn it all around :)</p>