title: Validate a Kivy TextInput on Input as Data Type Integer Before Accepting Input
body: <p>I am trying to validate a TextInput in Kivy before doing calculations on the value of the Input before Updating the calculated data to a ListView.  But when I test the first TextInput value by printing it out there is nothing, no error and no result.  I have referenced the on_press root.calvariable method AddKalibrasieForm Class in my Kivy file, but still nothing.  Can someone please give me a clue to what I am doing incorrectly?</p>
  
  <p>Edit:  I have noticed what I did wrong:  I imported TextInput without declaring the Class (it has been removed) and did not declare the val_lewerha TextInput object in the correct method (fixed it), so it prints to the console.  My question has changed to can you validate an users Input on Input? Is this called on_focus? e.g. of what method I think should achieve the desired result:</p>
  
  <pre><code>def validate_input(self):
      if isinstance(self.textinput, (int, float)):
          accept self.textinput
      else:
          make self.textinput color red as incorrect data type
  </code></pre>
  
  <p>2nd Edit:  I must have missed it, but another two Stack Overflow Q&amp;A's got me to the correct answer, 
  <a href="https://stackoverflow.com/questions/33464998/best-practice-for-textinput-validation-in-kivy-kv#comment54718843_33464998">Stack_Overflow_Answer1</a>;
  <a href="https://stackoverflow.com/questions/25296508/set-the-width-property-for-textinput">Stack_Overflow_Answer2</a>.
  I also skimmed past the Kivy Documentation that showed an example of only allowing floating point numbers and one point in a TextInput on inserting text
  <a href="https://kivy.org/docs/api-kivy.uix.textinput.html" rel="nofollow noreferrer">Kivy1.11.0_TextInput_Documentation</a>.  So I will be able to solve it.
  @eyllanesc:  I only want to allow a user to insert floating point '0-9' in the TextInput, no strings.  Thanks. How do I mark this as answered?</p>
  
  <p>Here is my Python3 code as is:</p>
  
  <pre><code>from kivy.app import App
  from kivy.uix.boxlayout import BoxLayout
  from kivy.properties import ObjectProperty
  
  class AddKalibrasieForm(BoxLayout):
      calculated_results = ObjectProperty()
  
      def convert_calvariables(self):
          val_lewerha = ObjectProperty()
          not_filled_in = ""
          flowha = float(self.val_lewerha.text)
          if flowha != not_filled_in and isinstance(flowha, (int, float)):
              print(format(self.val_lewerha.text))
          else:
              print("Error")
  
  class CalibrationApp(App):
      pass
  
  if __name__ == '__main__':
      CalibrationApp().run()
  </code></pre>
  
  <p>Here is a part of my Kivy file: calibration.kv</p>
  
  <pre><code>AddKalibrasieForm:
  
  &lt;AddKalibrasieForm&gt;:
      orientation: "vertical"
      val_lewerha: volha_box
      calculated_results: calculated_results_table
      BoxLayout:
          height: "40dp"
          size_hint_y: None
          Label:
              text: "Lewering per ha"
              size_hint_x: 25
          TextInput:
              id: volha_box #TextInput object name
              size_hint_x: 50
          Label:
              text: "liter"
              size_hint_x: 25
              text_size: self.size
              halign: "left"
      BoxLayout:
          height: "60dp"
          size_hint_y: None
          Label:
              size_hint_x: 35
          Button:
              text: "Bereken"
              size_hint_x: 30
              on_press: root.convert_calvariables() #method called on_press
          Label:
              size_hint_x: 35
      ListView:
          id: calculated_results_table
          table_items: []
  </code></pre>