I would like to disable the stop button (X) in the upper right hand corner. I found one solution on this forum, but that doesn't seem to work anymore.
So my question is on how to disable the X button (hide the status bar?)?
Forum Archive
Disable stop button (X) in Scene
Hi,
This works for me, you have to slide two fingers on screen to close it.
# Hide X button
import ui
view = ui.View(bg_color = 'slateblue')
view.present('sheet', hide_title_bar=True)
That's a solution for UI. How do I do that in Scene?
iirc for scene you need to use a SceneView and use this approach.
Maybe stupid, but how do I do that?
Hide_title_bar does not work for me. Not sure why people recommend it.
This is a solution I came up with.
class MyScene(scene.Scene):
def setup(self):
self.label = scene.LabelNode('Test hide title bar',
position=self.size/2, parent=self)
self.hide_close()
def hide_close(self, state=True):
from obj_util import ObjCInstance
v = ObjCInstance(self.view)
# Find close button. I'm sure this is the worst way to do it
for x in v.subviews():
if str(x.description()).find('UIButton) >= 0:
x.setHidden(state)
scene.run(MyScene())
This worked for me using Pythonista 3, where v is an instance of a class derived from ui.View.
v.present(title_bar_color='#000000',
hide_close_button=True,
orientations=['portrait'])
Obviously, you only need the "hide_close_button=True" part.
By the way, I'm relatively new here, and I still don't know how to post code so the formatting remains intact. I just searched for how to do that for 5 minutes and was unsuccessful. If anyone replies how to do that, I'll fix this post.
Update: Thanks dgelessus.
@technoway You can put three backticks before and after the code, like so:
```
your code here
```
becomes
your code here
You can also add python right after the first three backticks to get Python syntax highlighting.
@dgelessus @technoway Or just use the ` button in the editor. Addingpython` should usually not be necessary, syntax highlighting will mostly work without it.
Indented by 4 spaces also works for code blocks.
@technoway, I use a simple trick @ccc mentioned a long time ago. In 'Settings->Keyboards->Text Replacement' use 3 x comas to output 3 x ticks `
Not often you type 3 comas in a normal workflow.
@Phuket2 That's a great idea!