A note on how to launch a Pythonista 3 script from the iOS Share menu.
iOS has a sharing menu that allows you to pass data to other apps, and you will see the following icons in various situations. In the menu that appears when you tap this, in addition to the standard ** AirDrop **, ** message **, ** mail **, there are installed apps that support ** shared sheet **. The lineup and ** actions ** corresponding to the operation at that time are also displayed. Run Pythonista Script When ** Pythonista3 ** is installed, a menu called ** Run Pythonista Script ** will be added to the ** Actions column ** of the Share menu.
When you tap this menu, the icons of the scripts registered in advance will be lined up.
This is a script preset in **. / Examples / Extension **. Since you can register your own script here, you can also use it to receive data from other apps, process it, and then save it.The following sample rotates the received image 90 degrees clockwise and displays it on the console.
test.py
import appex
import console
def main():
if not appex.is_running_extension():
console.hud_alert('Please execute from the shared sheet.','error',2)
return
image = appex.get_image()
if not image:
console.hud_alert('Image not found.','error',2)
return
#Rotate the image and display it on the console.
image = image.rotate(270, expand=True)
image.show()
if __name__ == '__main__':
main()
I have made it so that it can only be executed from the share menu, so next I will make it possible to execute it from the share menu.
Share Extension Shortcuts
You can register ** Share Extension Shortcuts ** from the ** Pythonista ** settings screen, but you can also register from the share menu of the photo app, so try it from the photo app.
The original video link of the above GIF.
Recommended Posts