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.


    Detect when in the background

    Pythonista
    2
    4
    3353
    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.
    • hvmhvm
      hvmhvm last edited by

      Does anyone know if there is a way to detect when a running program (scene) is in the background (e.g. Because the user has pressed the home button)? I tried it with notifications (since I thought it reacts differently when the program scheduling a notification is in the background), but unfortunately all I managed was to crash Pythonista :-(

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

        I believe Scene.pause() may work. It says in the docs that the function gets called automatically when the home button is pressed while a scene is running.

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

          Nice suggestion! Unfortunately what I'm trying to do is quit the scene when the user presses the home button, but putting a sys.exit() in there doesn't stop the scene. I also tried to use a delay(0,lambda: sys.exit()), but then the scene ends after relaunching Pythonista. Since what I really want to do is allow for the launch of another program using the pythonista:// custom url, I get the error message 'Already running script' :-(

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

            In the end, using the pause, and using notification('',0,'','pythonista://test?action=run') it 'works' because that crashes the app in the background (but that is not the right way to do it)...

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