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.


    Need hellp with Ui.View.close method

    Pythonista
    ui.view.present scene
    2
    6
    5051
    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.
    • Bjucha
      Bjucha last edited by

      Hello I have added a ui.view on my scene that is displayed when my game starts, and at the same time the Scene.Paused = True condition is activated. Here is The problem I want a button that when presse closes the ui.view using ui.view.close and starts the scene, however I cant get the ui.view.closee to work. I always get that main_view (name of the ui.view) is not defined in the button pressed function. I here is the code ```
      class view (ui.View):
      main_view = ui.View(name = 'Killer Aliens From Space!')
      main_view.present(title_bar_color = 'grey')

      def startup(sender):
      	
      	Scene.paused = False
      	ui.View.close(main_view) # Here is where it complains
      		
      
      b1 = ui.Button(title = "Start")
      b1.frame = (295,390,190,50)
      
      b1.background_color = '#b03206'
      b1.corner_radius = 15
      b1.tint_color = 'blue'
      b1.action = startup
      main_view.add_subview(b1)
      
      Any ideas why this is happening?
      1 Reply Last reply Reply Quote 0
      • cvp
        cvp last edited by

        Instead of

            ui.View.close(main_view) # Here is where it complains
        

        Use

            main_view.close() # Here is where it complains
        
        Bjucha 1 Reply Last reply Reply Quote 0
        • Bjucha
          Bjucha @cvp last edited by

          @cvp thanks but now it says that ’main_view’ is not defined. When pressing the button.

          cvp 2 Replies Last reply Reply Quote 0
          • cvp
            cvp @Bjucha last edited by cvp

            @Bjucha The little script here-after works correctly but I have commented the class and the scene lines because they are not needed, except if your script is longer
            Perhaps a problem of indentation if main_view is not known in startup def.

            import ui
            
            #class view (ui.View):
            main_view = ui.View(name = 'Killer Aliens From Space!')
            main_view.present(title_bar_color = 'grey')
             	
            def startup(sender):
             		
            	#Scene.paused = False
            	main_view.close() # Here is where it complains
            			
             	
            b1 = ui.Button(title = "Start")
            b1.frame = (295,390,190,50)
             	
            b1.background_color = '#b03206'
            b1.corner_radius = 15
            b1.tint_color = 'blue'
            b1.action = startup
            main_view.add_subview(b1)
            
            1 Reply Last reply Reply Quote 0
            • cvp
              cvp @Bjucha last edited by

              @Bjucha or use, in startup:

              	sender.superview.close()
              
              Bjucha 1 Reply Last reply Reply Quote 1
              • Bjucha
                Bjucha @cvp last edited by

                @cvp Thank you, that did the trick!!!

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