I have an app called Pythonista3 on my iPhone, but honestly I didn't use it properly. But Pythonista is quite powerful because it can develop applications on the iPhone. So I decided to do a lot of research on Pythonista and at the same time redo Python itself and post the findings on my blog. In the following, the part written as "Pythonista" is basically intended for Pythonista3.
Pythonista contains multiple source codes for Examples, but I'm not sure if I look at them as they are, so I'll create a small script and check the operation while looking at the Pythonista documentation. It seems that omz-software is developing it, so is the site official? There seems to be Documentation and Forum.
http://omz-software.com/pythonista/docs/ https://forum.omz-software.com/category/5/pythonista
Based on the information provided here, I will investigate while googled.
Pythonista Modules I'm doing Python on the iPhone, so it's more interesting to use an iPhone-specific library. So, let's look at the modules for Pythonista, including those dedicated modules.
Pythonista Modules has a lot of modules. I'm not sure about the priority, so I'll start from the top of the list.
appex
Listed at the top is appex.
appex - Using the Pythonista Sharing Extension http://omz-software.com/pythonista/docs/ios/appex.html
This seems to be used when linking data with "Share" from other applications. I don't really understand the internal mechanism of data linkage between applications, but for the time being, I found that it works if I do the following, so it's a memo.
Create the following on Pythonista3 and save it on your iPhone.
myappex.py
import appex
print(appex.is_running_extension())
print(appex.get_text())
There are two methods used in this script. is_running_extension () returns True when called as an App Extension. If you run it as a normal script, it will be False. Since this is a test we call as an App Extension, make sure that True is returned to the console.
The other is get_text (). Returns the text input received from the application. Here, this text is output to the console. I'm not sure exactly how an application passes text to other applications.
Next, register myappex.py created here in the App Extension. The registration method is as follows.
Click on the third part in the upper left of the editor to open the left pane, and click on the gear icon in the lower right to open Settings.
In Settings, under APP EXTENSIONS, click "Share Extension Shortcuts".
Click (+) and select myappex.py.
Keep the default "Edit Shortcut" and click "Done" in the upper right corner.
The appex script is now registered with the App Extension.
Then call this App Extension with share from another application, Check if it works.
Type in some text in the memo and share it. Here, write "test" and then click the share icon in the upper right.
Click on "Run Pythonista Script" at the bottom.
I have myappex registered as an App Extension, so click on it.
You can see that is_running_extension () returns True and get_text () receives the string "Tesuto" typed in the memo application.
Recommended Posts