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 hide status bar in scene?

    Pythonista
    7
    28
    9234
    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.
    • mikael
      mikael @Tey last edited by

      @Tey, this seems solvable. Could you first clarify whether you are developing with the ui or scene? I would expect scene if this is some type of a game, and ui otherwise.

      Your code snippet imports both, but only uses ui, as the scene class seems not to be used.

      If you are really using scene only, you should not be using present, only scene.run.

      If you are using ui, you can use the workaround I mentioned above to hide the Apple stuff at the top.

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

        If you import * from objc_util, then erase the objc_util before UIApplication.

        But yes, there is a different solution for scenes inside sceneview, versus scenes using Scene.run

        cvp 1 Reply Last reply Reply Quote 0
        • Tey
          Tey @mikael last edited by

          @mikael
          I am new to all this, so I’m not sure what you mean by “developing with”. I am using both scene and ui. I create menus by calls to ui, not with the UI builder.The program begins with menu buttons appearing to float on top of the initially black scene (because the menu itself has alpha 0.) Pressing a button causes the buttons to disappear and an animation to begin. Pressing a navicon icon in the upper left of the scene causes the animation to stop and the buttons to return. Menus of buttons and controls will be dynamically created allowing the user to adjust animation parameters.

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

            @Tey, thank you for explaining. Since you are mostly building on scene with minor ui embellishments, and do not like the Apple stuff at the top, start with running the scene and then add ui elements as needed. Please see a minimal example below.

            With the mixed use, remember that for scene, y=0 is at the bottom, while for the ui views it is at the top.

            import ui
            import scene
            
            class Loop(scene.Scene):
                
                def setup(self):
                    self.background_color = 'black'
                    
                    btn1 = self.button1 = ui.Button(
                        title='Animation 1',
                        background_color='grey',
                        tint_color='black',
                        action=self.animation1,
                    )
                    btn1.size_to_fit()
                    btn1.width += 16
                    btn1.center = self.view.bounds.center()
                    self.view.add_subview(btn1)
                    
                    btne = self.end_button = ui.Button(
                        title='Stop',
                        background_color='transparent',
                        tint_color='grey',
                        action=self.show_menu,
                        hidden=True,
                    )
                    btne.size_to_fit()
                    btne.width += 16
                    btne.x = btne.y = 8
                    self.view.add_subview(btne)
                    
                def hide_menu(self):
                    self.button1.hidden = True
                    self.end_button.hidden = False
                    
                def show_menu(self, sender):
                    for node in self.children:
                        node.remove_all_actions()
                        node.remove_from_parent()
                    self.button1.hidden = False
                    self.end_button.hidden = True
                    
                def animation1(self, sender):
                    self.hide_menu()
                    ship = scene.SpriteNode('spc:PlayerShip1Orange')
                    ship.position = self.size / 2
                    self.add_child(ship)
                    ship.run_action(
                        scene.Action.repeat_forever(
                            scene.Action.rotate_by(1)
                    ))
            
            scene.run(Loop())
            
            
            Tey 1 Reply Last reply Reply Quote 0
            • cvp
              cvp @JonB last edited by

              @JonB said:

              If you import * from objc_util, then erase the objc_util before UIApplication.

              Of course, this is how my script does but I forgot to mention it, sorry.

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

                @mikael
                Thank you so much! It looks like it will do the trick. I won’t have time to apply it to my project for the next week or so but will get back to you.

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

                  We need to hide the status bar, navigation bar, and other things and only show the content we want to display!

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

                    I'm not sure if I understand the problem correctly, and I think a solution has already have been suggested.

                    However, I would recommend using scene.run() for presenting, and then adding UI elements e.g. in setup(), like this:

                    from scene import *
                    A = Action
                    
                    class MyScene (Scene):
                    	def setup(self):
                    		button = ui.Button(title='Tap me')
                    		self.view.add_subview(button)
                    	
                    	def did_change_size(self):
                    		pass
                    		# You may want to do layout here...
                    	
                    	# ...
                    
                    if __name__ == '__main__':
                    	run(MyScene(), show_fps=False)
                    

                    (Modified just slightly from the standard Game/Animation template)

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