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.


    Override Scene exit button

    Pythonista
    3
    5
    3938
    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.
    • cjchallis
      cjchallis last edited by

      I wrote a party game using the Scene module that involves passing my phone around a lot. Someone inevitably pushes the corner 'X', which quits the game early. I haven't been able to see where to change this behavior. Much of the scene code is hidden in the _scene module. Any suggestions? I'm fine with having no exit for the game (force close the whole app to quit).

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

        import scene, ui
        
        class UnclosableScene(ui.View):
            def __init__(self, the_scene):
                scene_view = scene.SceneView()
                scene_view.scene = the_scene
                self.present(hide_title_bar=True)
                scene_view.frame = self.bounds
                self.add_subview(scene_view)
        
        class BlueScene(scene.Scene):
            def __init__(self):
                self.background_color = 'midnightblue'
                
        UnclosableScene(BlueScene())
        

        A two fingered swipe down will shutdown the scene.

        1 Reply Last reply Reply Quote 1
        • cjchallis
          cjchallis last edited by

          Thanks! I'll experiment with this and try to integrate it with my existing code.

          1 Reply Last reply Reply Quote 1
          • Webmaster4o
            Webmaster4o last edited by

            Clever solution, @ccc

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

              This worked great! Just one more question - I haven't worked with Pythonista's ui before, how do I keep the view from rotating? I'd like to keep it fixed in landscape.

              Nevermind - I added 'orientation = ['landscape]' as an argument to 'self.present'. Problem solved.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Powered by NodeBB Forums | Contributors