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 to show a value choosen in previous UI.

    Pythonista
    3
    7
    3562
    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.
    • yoyo
      yoyo last edited by

      I would like to know how to use common value between multiple UI screen.
      For example, when a user chooses something option in a top page, I want to display the value on next page as a default value. In my recogntion, to set value to a variable, we need to catch something event from pushing bottom or something.
      But I want to show a value choosen in previous screen as a default value in next screen.
      Could you please give me a advice to implement my hope.

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

        Buttons call their action when pressed. TextViews have the value in the text property, which you can copy when moving to the next screen. Other elements have other ways of reacting to user input. All of these are described in the in-app docs.

        If that does not help, please share the code you have and we can provide more specific suggestions.

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

          Depending on what you're trying to do, a function like this might be what you need. For this code to work, you would have a button's action set to button_open_view, and new_view has a text field that you want to be set to the button's title. You can modify the details to fit your specific UI.

          def button_open_view(sender):
              # gets called when user selects an option from the first view
              new_view = ui.load_view('new_view')
              new_view['textfield'].text = sender.title
              new_view.present()
          
          yoyo 3 Replies Last reply Reply Quote 0
          • yoyo
            yoyo last edited by ccc

            #This is a sample code based on my app.
            import ui
            Import random
            
            #This function is connected to a button in TopPage.pyui
            def screen_front(sender):
            	key = random.randrange(0,20,1)
            	v3.bring_to_front()
            
            # I would like to show ‘key’ value in Next.pyui as default value after
            # ‘v3.bring_to_front()’ execution. It means that key value in Next.pyui
            # is always different since a value of key is set with random method. 
            
            v1 =ui.load_view('Canvas')
            v2 =ui.load_view('TopPage')
            v3 =ui.load_view('Next')
            v1.add_subview(v2)
            v1.add_subview(v3)
            
            #Bring TopPage.pyui as top page UI.
            v2.bring_to_front()
            
            v1.present('sheet')
            
            1 Reply Last reply Reply Quote 0
            • yoyo
              yoyo @johnridesabike last edited by

              @johnridesabike
              @mikael

              Thanks for your reply. Is it possible to reflect setting value dynamically when we use bring_to_front()?

              1 Reply Last reply Reply Quote 0
              • yoyo
                yoyo @johnridesabike last edited by

                @johnridesabike I have tried your sample code. However, load_view generate new screen, right? What I want to do is to change screen without exit button located on title bar...

                1 Reply Last reply Reply Quote 0
                • yoyo
                  yoyo @johnridesabike last edited by

                  @johnridesabike Based on your sample, I was able to implement my requirement! Thank you so much.

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