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.


    Change the View (without NavigationBar)

    Pythonista
    4
    11
    5844
    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.
    • NRWTV2
      NRWTV2 last edited by

      Heyy!!
      I got two pyui Files: intro.pyui and mail.pyui, if i start the code only intro.pyui is shown on the screen, now i added a button called "Open Mail", now i want to hide "intro.pyui" and open "mail.pyui".

      But how?
      Thx

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

        @NRWTV2 , I tried several things to remove the first view. I didn't work it out.
        But here is something. Maybe it still works for you.

        
        # coding: utf-8
        
        import ui
        
        
        def button_action(sender):
        	sender.superview.hidden = True
        	sender.v2.present('sheet', animated = False)
        	
        	
        
        f = (0,0,500,500)
        v1 = ui.View(frame = f, bg_color = 'white')
        btn = ui.Button(frame = (10,10,150,32), title = 'hit me')
        btn.border_width = .5
        btn.corner_radius = 3
        btn.action = button_action
        v1.add_subview(btn)
        
        v2 = ui.View(frame = f)
        v2.bg_color = 'pink'
        
        btn.v2 = v2   # not a attr of ui.Button, is being dynamically created
        v1.present('sheet')```
        1 Reply Last reply Reply Quote 0
        • Webmaster4o
          Webmaster4o last edited by

          Add the second as a subview to the first, and it'll be on top of everything.

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

            @Webmaster4o , but to remove the first view presented

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

              Have one view. Present it. Add pyui file A as a subview. Then remove pyui file A, and add B.

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

                @Webmaster4o , ok. But have you tried it? I tried with ui.Views. Not easy to get rid of that pesky first view

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

                  @Phuket2 a minimal example:

                  import ui
                  
                  container = ui.View()
                  a=ui.load_view('intro.pyui')
                  b=ui.load_view('mail.pyui')
                  
                  def switch_to_mail():
                  	container.remove_subview(a)
                  	container.add_subview(b)
                  
                  container.add_subview(a)
                  container.present(hide_title_bar=1)
                  ui.delay(switch_to_mail,1)
                  
                  NRWTV2 Phuket2 2 Replies Last reply Reply Quote 1
                  • NRWTV2
                    NRWTV2 @Webmaster4o last edited by

                    @Webmaster4o
                    Thanks, i will try it later!

                    1 Reply Last reply Reply Quote 1
                    • Phuket2
                      Phuket2 @Webmaster4o last edited by

                      @Webmaster4o , oh ok. See what you mean now

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

                        Try this:

                        def openMail(sender):
                            global View
                            View.close()
                            View.wait_modal() #VERY IMPORTANT, waits for view to close completely
                            View = ui.loadview('mail.pyui')
                            View.present('sheet')
                        
                        
                        
                        View = ui.loadview('intro.pyui')
                        mail_button = ui.ButtonItem(action=openMail, title = 'Open Mail')
                        View.right_button_items =[mail_button]
                        View.present('sheet')
                        
                        Webmaster4o 1 Reply Last reply Reply Quote 0
                        • Webmaster4o
                          Webmaster4o @jbap last edited by

                          @jbap It's better to switch them inside a container. That means that there is always a window, it is never dismissed. With your solution, the user waits for the UI to close and reopen.

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