Search code examples
pythonkivy

How to accept only numeric input (double) in kivy


I want my Textinput to accept only float input directly from python code. Here is what I have attempted:

TextInput(hint_text='Kgs', input_filter = float, multiline=False, write_tab=False)

But it gives the following error:

 TypeError: float expected at most 1 arguments, got 2

The following works in kv files:

TextInput:
  id: password
  input_filter: 'int' #For accepting ints

                        

What is the correct way of doing in python file?


Solution

  • the argument is a string so I think you should try this.

    TextInput(hint_text='Kgs', input_filter = 'float', multiline=False, write_tab=False)