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.


    Buttons not read from pyui

    Pythonista
    4
    8
    5473
    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.
    • Gadgettyke
      Gadgettyke last edited by

      Hi
      Installed pythonista yesterday and have got a very odd problem. It may well be a stupid one but as a noob I just can’t figure it out.

      Have read the documentation but still puzzled.

      I’m trying to read buttons from a pyui with no success at all, however if I run the example files they all work perfectly. I’ve even copied text directly intomy py files and they still don’t work

      If I create labels, I can read and write to them ok but buttons just refuse to work

      Altering the calculator py works but if I substitute my pyui file they stop working.

      Is it my creation of a pyui that’s the problem?

      I’m working on a brand new iPad Pro 2017 256mb os11.3.1

      Apologies if this is covered elsewhere and pointers to solutions welcome

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

        are you getting an error? or justactions are not being run? are you setting the action name in the pyui? are you sure you have those functions define before loading the pyui?

        Post your pyui and script as a gist (share menu) and we can take a look

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

          Have you read all the comments in the getting started section? Here Or do you create a pyui project with a separate pyui file? Then you could write e.g. button_tapped in the Action field in the button preferences.

          import ui
          
          def button_tapped(sender):
              sender.title = 'Hello'
          
          v = ui.load_view()
          v.present('sheet')
          
          1 Reply Last reply Reply Quote 0
          • Gadgettyke
            Gadgettyke last edited by

            Here is the code, I’ll work out how to do a gist and send the pyui from there
            try.py
            import ui

            def button_action(sender):
            '@type sender: ui.Button'
            # get button title
            t = sender.title
            print(t)

            v = ui.load_view('try')
            v.present('sheet')

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

              No errors just nothing. The button on the sheet animates but the action in the py does nothing.

              Pyui was created in pythonista. The examples work ok

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

                I think that worked ok

                https://gist.github.com/bf248fc278ffe1ac300a5229b59177f5

                Phuket2 1 Reply Last reply Reply Quote 0
                • Phuket2
                  Phuket2 @Gadgettyke last edited by

                  @Gadgettyke, looks like you just forgot to put your function name in action property of the button in the ui designer. ie button_action.

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

                    DOH!!! MANY THANKS

                    I just knew it would be a nooby mistake.

                    Must admit other than that I’d had very few difficulties in creating my app.

                    I Look forward to many hours of writing them.

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