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.
Pythonista opening in Workflow Today Widget
-
I wrote a little script in Pythonista that reads the song from my favorite radio station. This combined with a (Apple) Workflow adds this title to a playlist.
Now my problem is, that I want to start the Workflow script as Today Widget. But if I do so, Pythonista is always opened and the the Workflow script stops until I go back from Pythonista.
Is there any way to run Pythonista-Script in background when executing inside a Workflow? It's not really helpful when I have to interact each time.
Thanks already in advance! -
It's not possible to start a Pythonista script in the background while Workflow is open (or vice versa). However you can automatically switch between the two apps.
In Workflow, you can use the "Run Script" action to open Pythonista and run a script. You can also call the
pythonista3://
URL scheme manually using the "Open URLs" action, this allows you to use some more advanced options that the "Run Script" action doesn't support. For example, the URL scheme can be used to run scripts from (Pythonista's) iCloud, and to pass command-line arguments (sys.argv
) to the script. For details, see the chapter "The Pythonista URL Scheme" under "Using Pythonista" in the Pythonista docs.In Pythonista, you can open Workflow by using
webbrowser.open("workflow://")
. This just opens Workflow without doing anything else, which can be useful if you called a Pythonista script from Workflow and want to return to the workflow. If you do that, you should also add a "Wait to Return" action to your workflow directly after you call the Pythonista script. That way the workflow won't continue running in the background while the Pythonista script is running.Workflow also has its own URL scheme, which you can call using
webbrowser.open
to start workflows from Pythonista. You can then open thepythonista3://
URL from your workflow to return to Pythonista. However, Pythonista has no equivalent to Workflow's "Wait to Return" action - the script will continue running while Workflow is open. So if your remaining Python code depends on the workflow having finished, you may need to put it in a second script and have the workflow call that once it's done - that way you can be sure that it isn't executed early.By the way, the first time an app tries to programmatically open another app, iOS will ask you for permission. You only need to confirm this once, afterwards iOS will remember and won't ask about that combination of apps again. That means you might get an alert the first time you run a workflow/script that interacts with Pythonista/Workflow, but after that all interactions will happen fully automatically.
-
Ok thanks for the workaround! I will try it.