Redo Python in Pythonista3 (1) --appex

Introduction

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.

What do you start with?

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.

image.png

In Settings, under APP EXTENSIONS, click "Share Extension Shortcuts". image.png

Click (+) and select myappex.py. image.png

Keep the default "Edit Shortcut" and click "Done" in the upper right corner. image.png

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. image.png

Click on "Run Pythonista Script" at the bottom. image.png

I have myappex registered as an App Extension, so click on it. image.png

You can see that is_running_extension () returns True and get_text () receives the string "Tesuto" typed in the memo application. image.png

Recommended Posts

Redo Python in Pythonista3 (1) --appex
Python in optimization
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
Meta-analysis in Python
Unittest in python
Epoch in Python
Discord in Python
Sudoku in Python
DCI in Python
quicksort in python
nCr in python
N-Gram in Python
Programming in python
Plink in Python
Constant in python
Lifegame in Python.
FizzBuzz in Python
Sqlite in python
StepAIC in Python
N-gram in python
LINE-Bot [0] in Python
Csv in python
Disassemble in Python
Reflection in Python
Constant in python
nCr in Python.
format in python
Scons in Python3
Puyo Puyo in python
python in virtualenv
PPAP in Python
Quad-tree in Python
Reflection in Python
Chemistry in Python
Hashable in python
DirectLiNGAM in Python
LiNGAM in Python
Flatten in python
flatten in python
Daily AtCoder # 36 in Python
Clustering text in Python
Implement Enigma in python
Daily AtCoder # 32 in Python
Daily AtCoder # 6 in Python
Daily AtCoder # 18 in Python
Edit fonts in Python
Singleton pattern in Python
File operations in Python
Read DXF in python
Daily AtCoder # 53 in Python
Key input in Python
Use config.ini in Python
Solve ABC168D in Python
Daily AtCoder # 7 in Python
LU decomposition in Python
One liner in Python
Simple gRPC in Python
Daily AtCoder # 24 in Python