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.
Flick button keyboard.
-
@cvp said:
@shinya.ta No shame to not know something if you don't need it. I guess that you never needed to import a new module in Pythonista.
For GitHub, you don't need to really use it because I suppose that you never will post a source code but you need to learn the minimum to get a source code.
If you tap a link like https://raw.githubusercontent.com/cvpe/Pythonista-scripts/master/Emojis%20Keyboard.py, you open Safari at the GitHub site where a script is available in raw mode, that will say that you are able to select all, copy and paste in Pythonista.
I guess that you can create a new empty script in Pythonista and paste in it some copied code.
Now, if you select, copy and paste this little script in a new empty script in Pythonista
import os import requests url = 'https://raw.githubusercontent.com/mikaelho/pythonista-gestures/master/gestures.py' data = requests.get(url).content dir = os.path.expanduser('~/Documents/') file_name = url.split('/')[-1].replace('%20', ' ') path = dir + '/' + file_name with open(path,mode='wb') as out_file: out_file.write(data)
And you run it, it will get the code of gestures.py from GitHub and copy it to your site-packages folder as gestures.py. And from now for ever, any script can import gestures. All is automatic after you have run the little script. Then no need to understand GitHub.
If you have run it and if you have already pasted the new Emojis Keyboard.py, as you are used to do, now the new code can run because you have imported the gestures module. At least, I hope.
This was the 1st lesson 🙂
The paste is done.
But nothing happens when you do it. -
@shinya.ta said
The paste is done.
But nothing happens when you do it.The paste of what and where?
Nothing happens when you do what?
If you speak of the run of the little script: when you run, nothing visible happens, but a script is invisibly downloaded from GitHub to your Pythonista.If you go in the Pythonista console (I hope you know what it is), and you begin to type
"Import ges", do you see this
Please, explain always what you did before each question, I can't follow what you do
-
@cvp
I pasted a small script into an empty file and ran it. -
@shinya.ta hoping that you run the small script installing the gestures module, did you try to type "import ges" in the console and what's the result?
-
Where is "Pythonista console"?
I think I'm misunderstanding something. -
@shinya.ta On iPad or iPhone, swipe right to left and console appears.
At the bottom, you can type Python line -
I see ">>> import gesTraceback (most recent call last) : File" <string> ", line one, in <module> ModuleNotFoundError : No module named' ges'".
-
@shinya.ta ok, that will say that you have pressed the enter key. But without pressing the enter key, do you see
If yes, that will say that the copy of gestures.py from GitHub has been successful
-
@cvp
It will say ">>> import gestures". -
@cvp said:
@shinya.ta ok, that will say that you have pressed the enter key. But without pressing the enter key, do you see
If yes, that will say that the copy of gestures.py from GitHub has been successful
It doesn't look like this.
-
@shinya.ta please, copy this script and paste in a new empty script, then run it
import os import requests url = 'https://raw.githubusercontent.com/mikaelho/pythonista-gestures/master/gestures.py' data = requests.get(url).content dir = os.path.expanduser('~/Documents/site-packages') file_name = url.split('/')[-1] path = dir + '/' + file_name with open(path,mode='wb') as out_file: out_file.write(data)
Then retry to type "import ges" in console
-
@cvp
I entered "import ges" but the reaction is the same as before. -
Try writing this as a text file (not bytes) to the local directory instead of
site-packages
import os import requests url = 'https://raw.githubusercontent.com/mikaelho/pythonista-gestures/master/gestures.py' data = requests.get(url).text dir = os.path.expanduser('~/Documents/') file_name = url.split('/')[-1] path = dir + '/' + file_name with open(path,mode='w') as out_file: out_file.write(data)
-
@ccc said:
Try writing this as a text file (not bytes) to the local directory instead of
site-packages
import os import requests url = 'https://raw.githubusercontent.com/mikaelho/pythonista-gestures/master/gestures.py' data = requests.get(url).text dir = os.path.expanduser('~/Documents/') file_name = url.split('/')[-1] path = dir + '/' + file_name with open(path,mode='w') as out_file: out_file.write(data)
I tried it.
The last line will say "UnicodeEncodeError". -
data = requests.get(url).text # <-- text, not context?
with open(path,mode='w') as out_file: # 'w' not 'wb' ?
-
-
@shinya.ta @ccc believe me, I use my script very often and it works successfully each time, no reason to change it.
-
@shinya.ta last try in another way.
Go to https://raw.githubusercontent.com/mikaelho/pythonista-gestures/master/gestures.py,
Long press on text, then “select all”, then “copy”
Then, in Pythonista, create an empty script named gestures.py (no uppercase) in the folder where your “Emojis keyboard,py” is, and paste the copied code -
This post is deleted! -
@cvp
I copied and pasted it to a new folder.
Nothing special will happen.