Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
[Solved] Use the numeric keyboard easily
-
Hello!
I've created a very simple app to solve an small problem I have. The app works really well.
The app has a couple of text fields. These fields are numbers and I would like to use a numeric keyboard instead of the regular keyboard. I have created the ui using the UI Designer. Is there an easy way to do it? If it is too difficult (more than two lines of code), it isn't a big deal to change the keyboard when I'm using the app...
Sadly, my knowledge is very limited and I'm not able to understand half of the help. I have searched the forum and the internet looking for examples I could use, but no luck.
Thanks!
Javier
-
-
Hi!
I contacted Ole via Twitter and he solved the problem. It's really easy, but there are a couple of things that are not so evident (at least, for me).
To use a numeric keyboard with a textField created using the UI Designer you need to write in the Custom Attributes field:
{"keyboard_type": ui.KEYBOARD_DECIMAL_PAD}
Alternatively, you can write:
dict(keyboard_type=ui.KEYBOARD_DECIMAL_PAD)
I think the second is easier to write in iOS. The first one has one problem: the quotation marks. By default iOS changes the straight " " to typographic ones. The problem is that Pythonista cannot understand typographic quotation marks. You can get straight quotation marks by tapping and holding the ["] key.
I hope it's clear now (and that you could understand my not-so-good English).
Javier
Edit (27 June 2018): It's possible to change several attributes in one line. For example, here we change the keyboard to a decimal pad and make the Clear Button visible always:
{"keyboard_type" : ui.KEYBOARD_DECIMAL_PAD, "clear_button_mode" : "always"}
-
great info! I think this issue will come up for a lot of people
-
Thanks for the tips. One question: is there a way to minimize the numeric keypad once the user has completed the entry? With the standard alpha keyboard this is done by hitting 'return'. What is the equivalent on the numeric keyboard? Thanks again.
-
How would your application know when the user is done editing? I use a "calculate" button in my own app and then call the method end_editing() for all the text fields. That hides the numerical keyboard.
-
@stompertje - thanks for the quick reply. I was wondering if there was a way to enable a 'return' or 'enter' button on the keyboard itself. It appears, from reading other posts, that this isn't the case. Considering that, as you suggest, I will need a way to indicate that the user input is complete - the 'calculate' button is a good idea and should fit well within the application I'm putting together. Thanks again.
-
-
@cvp thank you for the link