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.
"Unsupported File Type"
-
This is probably a feature request (although I'd be interested if anyone has a work-around via script.) Also, I'm new to iOS so please forgive me if I don't get the terminology correct.
When I tap a file that Pythonista isn't familiar with I receive a message that reads:
Unsupported File Type
This file cannot be opened with Pythonista.Can we please instead have a screen that looks like this:
so that we can let other apps that have set up handlers open the files in question.
More information:
I use python scripts to update and retrieve information as part of my daily workflow. For example - I retrieved a database and a pdf from a client through Python. If I tap the pdf in file view Pythonista's built-in viewer opens it. It's a nice feature but more importantly it allows me (through the sharing widget) to share/export the file with other apps ('Open in:' iBooks, Kindle, Chrome, etc..) When I tap the database all I get is a prompt that reads 'Unsupported File Type' even if I have an app that has registered the file type and can open it.
Can you do it? Pretty please?
-
Yes, I plan to improve that. As a workaround, you could write a script that uses the
console.open_in()
function to send the file to another app. -
Ah, thank you!
-
One way you could do this is create a scipt that opens the pythonista unreadable file, opens the editor to a tmp.txt of that file. Then make your changes, switch back to console and save it. I do this with the shellista-ssh plugin for using nano on files on the server. I'll make a quick demestration for pythonista.
-
<pre>
import editor
import console
import oscurrent_file = editor.get_path()
current_dir = os.path.dirname(current_file)
os.chdir(os.path.expanduser('~/Documents'))
file_to_open = raw_input('Open which file? ')
TEMP = open(os.path.expanduser('~/Documents/tmp.txt'),'w')try:
f = open(file_to_open,'r')
TEMP.write(f.read())
TEMP.close()
f.close()
editor.open_file('tmp.txt')
raw_input('Press Enter to edit file. When you are finished editing open the console. ')
console.hide_output()
save = raw_input("Save File? [y/n]")
if save=='y' or save=='Y':
f = open(file_to_open,'w')
f.write(editor.get_text())
f.close()
except:
print 'File does not exist.'finally:
editor.open_file(current_file)
console.hide_output()
os.remove(os.path.expanduser('~/Documents/tmp.txt'))</pre>
-
I'd actually like to add a request to allow opening of text files that have extensions that are common for text files, like "ini" or "cfg". For example, when I use ConfigParser to save configuration or settings, I typically save it as an *.ini file, which then becomes uneditable.
Thanks to briarfox for a workaround.
-
I've been experimenting with using a javascript based editor, hosted in a
ui.WebView
, to open any type of file.For instance the ace editor is very full featured, I'm sure there are others. It supports hilihting, etc for hundreds of different languages. Presenting in a
panel
makes this very natural to swap back and forth between console.WebView
can open file:// type urls, if os.path.abspath is used. Using a webview delegate would allow custom callbacks, if needed, though one could also create the ui elements in pythonista, which call editor functions througheval_js
. -
@JonB, This sounds supercool... Would you be willing to create a repo of code?
-
I'm doing something using a javascript based editor, hosted in a ui.WebView, too. I've got it resizing nicely on orientation change and on keyboard activation / deactivation.
-
Here is what I came up with.
This uses editarea. I started with ace, but that seems to have keyboard issues on mobile.
I also tried codemirror... I really like some of the modes. There's a fork with ios support, but it is flaky, again keyboard/selecting.Then, I used editarea for a while, but it had an annoying ghosting issue. Later figured out opacity of hidden in css was too high, setting it lower mostly works. Sometimes keyboard doesn't work until you change focus, or min keyboard.
It does have tabbed multifile support, which I have turned off... Need to implement js to python callbacks through custom urls. Eventually a shellista plugin.I'd love to see how you handled orientation changes, etc!
-
I'm using CKEditor as I want wysiwyg editing of html.
For orientation it's easiest to addEventListener for orientationchange in the html.
There's no simple equivalent for the keyboard show/hide in the html ( though you could load a java package like http://github.com/driftyco/ionic-plugins-keyboard/tree/60b803617af49a10aff831099db90340e5bb654c ).
The simplest for that is to use a custom view and evaluate javascript in the keyboard frame will change.
-
Here's a little tool to browse files and use 'Open in' on any of them....
http://omz-forums.appspot.com/pythonista/post/6151216794959872
-
The shellista dev-modular branch now includes nano. It will open any file as text to allow editing.
-
@JonB I've now got all the resizing into the python script evaluating java. Here are the 5 events I'm handling and where:
1 initial size: set in webview_did_finish_load 2 orientation change (keyboard hidden): handled in View layout 3 orientation change (keyboard shown): handled in View keyboard_frame_will_change 4 keyboard shown: handled in View keyboard_frame_will_change 5 keyboard hidden: handled in View keyboard_frame_will_change
-
Do you have a repo someplace?
-
@JonB Here's the code... you'd have to adjust the View layout section if you have anything other than orientation changes triggering the layout.
# see code for EditView class
Edit: JonB... note it gives -90 not 270