2

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?

2 Answers 2

2

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

TextInput(hint_text='Kgs', input_filter = 'float', multiline=False, write_tab=False)
Sign up to request clarification or add additional context in comments.

Comments

0

In .kv file, we act like this:

TextInput:
        id:cal_input
        text:"0"
        halign: "right"
        font_size:65
        size_hint:(1,0.15)
        hint_text:'Only Numbers'
        input_filter : 'float'
        multiline:False
        write_tab:False

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.