Akash D G
Akash D G

Reputation: 188

how to make numeric keyboard in kivy(Python)?

how to make numeric keyboard in kivy like this,enter image description here

Upvotes: 1

Views: 4680

Answers (2)

Leonardo Rodriguez
Leonardo Rodriguez

Reputation: 34

set the input_type='number' in your TextInput widget. That will show the numeric keyboard only for that widget, for example in your case I think the best way yo make that widget is to create your own like this:

    class yourwidgetname(BoxLayout):
        def __init__((self, **kwargs):
            b = BoxLayout(orientation = 'horizontal')
            b1 = Button(text = '+')
            b2 = Button(text = '-')
            val = TextInput()
            val.input_type = 'number'
            b.add_widget(b1)
            b.add_widget(val)
            b.add_widget(b2)
            self.add_widget(b)
            super(yourwidgetname, self).__init__(**kwargs)    

I wrote it on the way I didn't try it but this is only to show the input_type property and I hope it gives enough light to the subject.

Upvotes: 0

Dawid Dave Kosiński
Dawid Dave Kosiński

Reputation: 901

it looks like the textinput is binded to an action while focusing on it that pops out a bubble. In the bubble I think you can make a gridlayout of buttons and bind a action that will change the text in the textinput.

Downloading the kivy framework you can check the examples of the widgets in the example/widgets/ directory. You just need to Combine several solutions.

Upvotes: 1

Related Questions