omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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

    Pythonista
    ui module ui.textview keyboard
    5
    9
    7785
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • runjaj
      runjaj last edited by runjaj

      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

      cvp 1 Reply Last reply Reply Quote 0
      • cvp
        cvp @runjaj last edited by

        @runjaj see here

        1 Reply Last reply Reply Quote 0
        • runjaj
          runjaj last edited by runjaj

          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"}

          1 Reply Last reply Reply Quote 1
          • estephan500
            estephan500 last edited by

            great info! I think this issue will come up for a lot of people

            1 Reply Last reply Reply Quote 0
            • njEd
              njEd last edited by

              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.

              1 Reply Last reply Reply Quote 0
              • stompertje
                stompertje last edited by

                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.

                1 Reply Last reply Reply Quote 0
                • njEd
                  njEd last edited by

                  @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 1 Reply Last reply Reply Quote 0
                  • cvp
                    cvp @njEd last edited by

                    @njEd see this topic

                    1 Reply Last reply Reply Quote 0
                    • njEd
                      njEd last edited by njEd

                      @cvp thank you for the link

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Powered by NodeBB Forums | Contributors