Numeric Keyboard with Kivy / KivyMD for MDTextField

742 Views Asked by At

How to make the Text Fields use the numeric android keyboard instead of the normal keyboard with all the letters? NOTE: I'm using KivyMD MDTextFields So when I click to write in the text fields a keyboard like this appears instead:

Like in this picture

2

There are 2 best solutions below

0
Code Clickers On BEST ANSWER

In the py file I created my own class for custom keyboard:

class CustomTextField(MDTextField):
    def __init__(self, *args, **kwargs):
        self.input_type = "number"
        self.input_type = "tel"
        self.input_filter = 'float'
        self.multiline = False
        super().__init__(**kwargs)

And then in the buildozer.spec file I changed the line:

p4a.branch = master

to:

p4a.branch = develop
0
patrick.genova On

I was having this same problem, I found an article where it said to use the input_type: 'number' inside your MDTextField that opens the android numeric keypad! I'm compiling my code again to see if it checks. Ex.:

MDTextField:
            id: quantidade
            pos_hint: {"center_x": .5, "center_y": .5}
            input_type: 'number'
            hint_text: "Qtd."
            helper_text_mode: "on_error"
            helper_text: 'Insira uma quantidade (Apenas Números, "," e ".")'