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.
    • Tey
      Tey last edited by

      That causes my screen to appear briefly, then the program terminates.

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

        @Tey That's because Pythonista crashes, this function needs to run in main thread
        See file _objc_exception.txt

        The app was terminated due to an Objective-C exception. Details below:
        
        2020-02-19 10:39:50.178902
        threading violation: expected the main thread 
        

        Try so

        @on_main_thread
        def x():
        	objc_util.UIApplication.sharedApplication().statusBar().hidden = True
        x() 
        

        No more crash but does not work, perhaps due to ios13

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

          @Tey, it does not make a lot of sense, but include title_bar_color='black' in present.

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

            @Tey, just checking the question. If I run the below, I get a full red screen with no extras except the ”X” to close. What happens on your device, and which device is it?

            import scene
            
            class Loop(scene.Scene):
            
                def setup(self):
                    self.background_color = 'red'
            
            scene.run(Loop()) 
            
            cvp 1 Reply Last reply Reply Quote 0
            • cvp
              cvp @mikael last edited by cvp

              @mikael said:

              include title_bar_color='black' in present.

              It works but I don't understand why.

              The status bar either disappears, either has its characters white???

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

                @mikael said:

                I get a full red screen with no extras except the ”X” to close.

                I too, but why?

                mikael 1 Reply Last reply Reply Quote 0
                • 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
                                            • First post
                                              Last post
                                            Powered by NodeBB Forums | Contributors