Disable stop button (X) in Scene
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?)?
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
your code here
You can also add
pythonright after the first three backticks to get Python syntax highlighting.
Indented by 4 spaces also works for code blocks.
@Phuket2 That's a great idea!