show only the numeric keypad in a Text Input

1,070 views
Skip to first unread message

coutinh...@gmail.com

unread,
May 9, 2021, 8:57:07 AM5/9/21
to Kivy users support
Good morning,

How do I show only the numeric keypad in a Text Input?

Elias Coutinho

unread,
May 10, 2021, 1:43:33 PM5/10/21
to kivy-...@googlegroups.com
Does anyone know how to change the kivy keyboard to numeric only?

Em dom., 9 de mai. de 2021 às 09:57, coutinh...@gmail.com <coutinh...@gmail.com> escreveu:
Good morning,

How do I show only the numeric keypad in a Text Input?

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/e24b2036-ac5c-4096-9e64-36216877be81n%40googlegroups.com.


--
Elias Coutinho.
Aprender sobre alguns assuntos é fundamental.
Aprender sobre Deus é indiscutivelmente o melhor conteúdo.

Nusli

unread,
May 11, 2021, 5:42:15 AM5/11/21
to Kivy users support

Elias Coutinho

unread,
May 11, 2021, 6:57:08 AM5/11/21
to kivy-...@googlegroups.com
I had already tested this.
Nothing happens, it shows the full keyboard.
There must be something missing to do!

Nusli

unread,
May 11, 2021, 7:22:52 AM5/11/21
to Kivy users support
I haven't developed a mobile app so far, but you could try looking into the keyboard and vkeyboard classes. This seems promising: https://kivy.org/doc/stable/api-kivy.uix.vkeyboard.html#request-keyboard

Elias Coutinho

unread,
May 11, 2021, 2:28:09 PM5/11/21
to kivy-...@googlegroups.com
I swear I tried to understand but didn't understand.
I was unable to display only the numbers on the keyboard.

qua non

unread,
May 11, 2021, 2:36:35 PM5/11/21
to kivy-...@googlegroups.com
Make sure to use kivy >=2.0.0 and p4a from develop branch textinput.input_type='numbers' should work.


Elias Coutinho

unread,
May 11, 2021, 3:00:04 PM5/11/21
to kivy-...@googlegroups.com
Do you have a short example of what the code would look like?

I don't know if I have p4a installed.
In the kivy documentation did not ask to install.

See in the image attached my versions:

Captura de tela de 2021-05-11 15-57-52.png

qua non

unread,
May 11, 2021, 4:19:37 PM5/11/21
to kivy-...@googlegroups.com
ok, so it seems you are using kivy on a desktop,  I assume on a touch screen using a vkeyboard, you should look into the link Nusli linked to https://kivy.org/doc/stable/api-kivy.uix.vkeyboard.html#request-keyboard

Elias Coutinho

unread,
May 11, 2021, 5:36:16 PM5/11/21
to kivy-...@googlegroups.com
I swear this part of the code I understood, however, I have no idea where to use it.
It is correct to say that I am using it on a desktop, it happens that in android the magic does not happen.
If you have an example code I would like to thank you.
keyboard = Window.request_keyboard(
    self._keyboard_close, self)
if keyboard.widget:
    vkeyboard = self._keyboard.widget
    vkeyboard.layout = 'numeric.json'

qua non

unread,
May 11, 2021, 6:39:26 PM5/11/21
to kivy-...@googlegroups.com
Here is a small workaround::

```
<WTextInput@TextInput>
    keyboard_mode: 'managed'
    kbdmode: 'qwerty'
    on_focus:
        if not self._keyboard:\
            self._ensure_keyboard();\
            self._keyboard.widget.layout = self.kbdmode
        self.show_keyboard() if args[1] else self.hide_keyboard()

BoxLayout
    WTextInput:
        kbdmode: 'azerty'
    WTextInput
```

It seems this api is not exposed. This would qualify as a bug. Please open a issue. tagging this conversation,  and `FocusBehavior` as the widget that needs fixing.

Reply all
Reply to author
Forward
0 new messages