title: Bind function to Kivy button
body: <p>I'm trying to bind the following function to a <code>Button</code> in Kivy.</p>
  
  <pre><code>def auth(self):
      print(self.username)
      if self.username == "Hendricko":
          print("self.username == Hendricko")
          popup = Popup(title="success",
              content=Label(text="Howdy !"),
              size=(100, 100),
              size_hint=(0.3, 0.3),
              auto_dismiss=False)
          popup.open()
  </code></pre>
  
  <p>I've tried</p>
  
  <pre><code>class Foo():
     def initUI(self):
      self.add_widget(Button(text="Auth User and Password", on_press=self.auth))
  </code></pre>
  
  <p>but this doesn't work. What am I doing wrong?</p>
  
  <p>here is my whole code</p>
  
  <pre><code>from kivy.uix.popup import Popup
  from kivy.app import App
  from kivy.uix.gridlayout import GridLayout
  from kivy.uix.label import Label
  from kivy.uix.textinput import TextInput
  from kivy.uix.button import Button
  from kivy.uix.boxlayout import BoxLayout
  from kivy.uix.stacklayout import StackLayout
  
  
  class LoginScreen(GridLayout):
      def __init__(self, **kwargs):
          super(LoginScreen, self).__init__(**kwargs)
          self.cols = 2
          self.row = 2
          self.add_widget(Label(text='User Name'))
          self.username = TextInput(multiline=False)
          self.add_widget(self.username)
          self.add_widget(Label(text='password'))
          self.password = TextInput(password=True, multiline=False)
          self.add_widget(self.password)
          self.hello = Button(text="hello", on_press=self.auth)
          self.add_widget(self.hello)
  
      def auth(self):
          if self.username == "Hendricko":
              popup = Popup(title="success",
                  content=Label(text="Howdy !"),
                  size=(100, 100),
                  size_hint=(0.3, 0.3),
                  auto_dismiss=False)
              popup.open()
  
  
  class MyApp(App):
      def build(self):
          return LoginScreen()
  
  
  if __name__ == '__main__':
      MyApp().run()
  </code></pre>