Thank you. It works very well!
How would I know how to do this without your post though? Should I be reading the objective C iOS api from Apple, or something?
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.
Thank you. It works very well!
How would I know how to do this without your post though? Should I be reading the objective C iOS api from Apple, or something?
I have a script here that runs google image search on whatever URL is in clipboard.
It works perfectly **in Pythonista. **
But I want it to work from within Safari (That means from Safari->'Run Pythonista Script'->'My script.py'.
It will not open the tab if run in this way from Safari. Is there a way to make this work?
My code is simply:
import clipboard
import webbrowser
def is_url(image_url):
''' Accepts a url [string]. Returns True if url is valid. '''
try:
return image_url.startswith('http://')
except:
print 'Invalid URL.'
return False
def create_url(image_url):
''' Accepts an image_url [string]. Returns search by image URL. '''
search_url = 'https://www.google.co.uk/searchbyimage?&image_url='
try:
search_url += image_url
except:
print 'Could not create URL from clipboard.'
return search_url
def main():
image_url = clipboard.get()
if is_url(image_url):
search_url = create_url(image_url)
webbrowser.open('safari-' + search_url)
print 'Done.'
if __name__ == '__main__':
main()```
I always work with two files open side-by-side from my desktop. However, it doesn't seem I can do this with Pythonista.
Please consider the option of allowing two files open side-by-side. This makes test-driven development far easier (when you can see the tests and the code at the same time)
Thanks!
I'll answer my own question. py files are stored in the following Pythonista directory on the iPad Pro running iOS 9.3.3:
/var/mobile/Containers/Shared/AppGroup/Random_String/Pythonista3/Documents
What is the absolute directory where Pythonista scripts are stored?
Pythonista.app does not exist in /Applications
(Assume I have access to the full file system)