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?
-
How can I keep the status bar (giving time, date, .... battery level) from appearing at the top of my scene?
import scene import ui 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)) v.present('full_screen', hide_title_bar = True)
- list item
-
import objc_util objc_util.UIApplication.sharedApplication().statusBar().hidden = True
Add that after you present your script.
-
That causes my screen to appear briefly, then the program terminates.
-
@Tey That's because Pythonista crashes, this function needs to run in main thread
See file _objc_exception.txtThe 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
-
@Tey, it does not make a lot of sense, but include
title_bar_color='black'
inpresent
. -
@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())
-
@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???
-
-
@cvp, because
scene
is notui
, and this is how it is supposed to work?ui
has issues not really supporting removing the extras withpresent
*), but if OP had the issue withscene
as the title suggests, I do not see the problem.*) Workaround:
run
a scene, then use itsview
attribute as you would any otherui
root view. -
@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 😂
-
@cvp, congratulations!
-
@mikael Thanks
-
@cvp, Grand Old Man of Pythonista? :-P
-
@mikael Ho no, believe me. I've just enough free time to test/try a lot.
-
@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?!?
-
@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)
-
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!
-
@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 dofrom 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
-
@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 *
-
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)