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.


    How can i pass data between different scenes and/or ui views

    Pythonista
    4
    16
    6081
    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.
    • walterwang
      walterwang last edited by

      I get a completely black screen when set pause to true and then set it to false

      mikael 1 Reply Last reply Reply Quote 0
      • enceladus
        enceladus last edited by

        Look at the brickbreaker example in examples/games folder (BrickBraker.py in Examples/Games). It uses 'pause and present_modal_scene for displaying menu and I hope it will be useful in understanding . (BTW, you can also use global variables to pass data.)

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

          https://gist.github.com/6dacbc24e874bf4458772cc4a2bc4aad
          This is an example of using pause in a sceneview

          1 Reply Last reply Reply Quote 1
          • mikael
            mikael @walterwang last edited by

            @walterwang, could you briefly explain why you want to run the blocking login request in Scene?

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

              @mikael I have a login screen which when authenticated gets a request.cookie that is used to identify the user as a session in flask. The setup screen requires information from the user's account, and therefore cannot be updated or rendered until the user logs in from the login screen. But once logged in, I only need to post the request once to get the needed information. So far I have a try block and a setup_query_once = True boolean, which is set to false after setting up once in the update function.

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

                why not just handle evrything in your login code, i.e inside the ui callback? it seems really clunky to do that within update.

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

                  @JonB, I can do that with the request cookies part of the login, but there is also additional information that needs to be rendered only once. This information is only available once you log in.

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

                    What I mean is, the login code should be run in the UI portion of the code. Then once you are logged in, begin rendering the scene (using pause). Did you try the example above that showed use of pause?

                    I would just worry about running anything blocking or time consuming within the update loop. I think your original code would have kept trying to login -- you should only send a single login request, and only retry with a timeout.

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

                      Hi JonB thanks for the advice. sorry the code I posted here was too simplified, (My actual code was just a single if statement testing a boolean variable) But I have changed it to a better way of adding subview, I don't know why it didn't work at first. So the login code is in the setup now. I haven't tried using pause yet, so far I am just using add_subview when initializing the scene for the first time, and scene.hidden =True to hide the previous menu.

                      Thanks for all the help!

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

                        out of curiosity ... what is this going to become? a multiplayer game?

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

                          yes, its a turn based multiplayer game. It will be a lot like chess.

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