Forum Archive

Executing a Pythonista script in Apple Shortcuts

jkoen

Hi Pythonista,

I recently bought Pythonista because I thought it could help me to sort and build dictionary outputs from "Get contents of URL" in Shortcuts. I must say so far I have been very disappointed

My first issue I got:
I found the script "Run script" does not pass the actual arguments. With a bit of googling I found that you could use the URL script as a workaround.

Second Issue
So if I use URL to call the python script it then opens actual Pythonista and then you have to manually switch back to Shortcuts. Really? I can see the content passed back to the clipboard on Shortcuts from the clipboad.set function but the opening of Pythonista is a "no go"

Is there a way that I can use the script "Run script" and pass it arguments as it is intended for?
if not and I'm forced to use the script URL, how can I get it to not switch screens from Shortcuts to Pythonista?

Im running IOS 15.1

I would appreciate any advice
Kind Regards
Johnny

cvp

@jkoen Your shortcut can run a PyThonista script and pass an argument via url scheme

Url = pythonista://MyScript?action=run&args=argument
Open url

Your script can recall your shortcut via url scheme

webbrowser.open("shortcuts://run-shortcut?name=[name]&input=[input]&text=[text]")

See https://support.apple.com/en-en/guide/shortcuts/apd624386f42/ios