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
    9235
    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 @cvp last edited by

      @cvp, because scene is not ui, and this is how it is supposed to work?

      ui has issues not really supporting removing the extras with present *), but if OP had the issue with scene as the title suggests, I do not see the problem.

      *) Workaround: run a scene, then use its view attribute as you would any other ui root view.

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

        @mikael Already understood in the past and forgotten. 70 years old today, thus perhaps too old for this kind of stuff 😢 If you say "yes", I kill you 😂

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

          @cvp, congratulations!

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

            @mikael Thanks

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

              @cvp, Grand Old Man of Pythonista? :-P

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

                @mikael Ho no, believe me. I've just enough free time to test/try a lot.

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

                  @cvp said:

                  70 years old today

                  How would you use Python to determine how many days old you are? Hint: use actual birthdate and 70 year birthday date to avoid any off-by-one errors for leap years.

                  Extra credit: How many leap seconds have you live through so far?!?

                  cvp 1 Reply Last reply Reply Quote 1
                  • cvp
                    cvp @ccc last edited by

                    @ccc said:

                    How would you use Python to determine how many days old you are?

                    Sure you will have shorter

                    from datetime import date
                    d0 = date(1950,2,19)	# birthdate
                    d1 = date.today()
                    delta = d1 - d0
                    print(delta.days) 
                    
                    1 Reply Last reply Reply Quote 0
                    • Tey
                      Tey last edited by

                      My ... we do wander off topic don’t we?

                      I’m running 13.3.1 on an iPad Pro (12.9 inch) (2nd generation)

                      My problem is with the status bar, not the title bar. The title bar is the one with the X used to terminate the program. It can be made to completely disappear using hide_title_bar = True, as in my original post.

                      The status bar is an Apple thing. It contains time and date at the left and battery indicator among other things at the left. You see it at the top of your main screen.

                      So, to summarize:

                      @JonB your suggestion of
                      import objc_util
                      objc_util.UIApplication.sharedApplication().statusBar().hidden = True

                      for reasons unknown to me no longer causes the screen to appear for a split second before Pythonista terminates. The program no longer terminates but the status bar is still present.

                      @cvp your suggestion of
                      “@on_main_thread
                      def x():
                      objc_util.UIApplication.sharedApplication().statusBar().hidden = True
                      x() “

                      causes a NameError, name on_main_thread is not defined. And the status bar is still there.

                      @cvp I have you beat by a decade. My first computer was an IBM 1620, used paper tape, took 180 microseconds to execute a NOOP and had a 40K digital memory. None of this newfangled octal or hexadecimal. Seventy may be the new fifty but eighty is still the same old eighty!

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

                        @Tey The suggestion of @JonB is correct but, since iOS 13 needs to run in main thread.
                        You can have the reason of the error in the _objc_exception.txt file after the crash
                        Thus, you need to do

                        from objc_util import *
                        .
                        .
                        .
                        @on_main_thread # comes from objc_util
                        def x():
                        .
                        .
                        

                        Thus, so no more crash but status bar still there because jonb suggestion is no more valid in iOS 13

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

                          @Tey said:

                          @on_main_thread
                          def x():
                          objc_util.UIApplication.sharedApplication().statusBar().hidden = True
                          x() “
                          causes a NameError, name on_main_thread is not defined.

                          NameError because we

                          import objc_util
                          

                          Instead of

                          from objc_util import *
                          
                          1 Reply Last reply Reply Quote 0
                          • Tey
                            Tey last edited by

                            Still get the NameError. Just to be clear, below is what ran. I’ve also run it with @JonB lines after v.present but of course still get the name error.

                            I’ll give up on this for now because in actual practice my screen is black not white and the status info only shows up when something light colored passes behind the status bar.

                            Thanks everyone for trying.

                            import scene
                            import ui
                            from objc_util import *
                            
                            class Loop(scene.Scene):
                            
                            	def setup(self):
                            		self.background_color = 'white'
                            
                            	def update(self):
                            		time = self.t 
                            
                            v = ui.View(frame=(0, 0, 1366, 1024))
                            
                            @on_main_thread # comes from objc_util
                            def x():
                            	objc_util.UIApplication.sharedApplication().statusBar().hidden = True
                            x() 
                            
                            v.present('full_screen', hide_title_bar = True)
                            
                            mikael JonB 2 Replies Last reply Reply Quote 0
                            • 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