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.
Outliner with drag/drop reordering - part 2
-
@cvp Probably an old Pythonista problem, but I just started a new outline entered three lines and then hit enter and Pythonista crashed.
-
@ihf said
Probably an old Pythonista problem, but I just started a new outline entered three lines and then hit enter and Pythonista crashed.
Unfortunately, this does not seem to be in my hands
But, anyway, try to check the reason in objc_exception.txt or faultlog folder
-
@ihf V01.21 and outline.versions with
Version V01.21 - correction of bug "when typing a long line automatically splits the line, the keyboard sometimes disappears and cursor is no more visible"
As I can't reproduce your problem (in my case, keyboard disappears), perhaps this correction does not solve your bug (but only mine). Please, give me some feedback
-
@cvp I tested v1.21 on the iPad and the keyboard remained visible (although it seemed to go away and come right back). So that seems to be fixed (I will test on the iPhone). However, I had a different (new?) problem. I added an item and then tried to move it by holding and dragging it. It looked like it was working, but when I released it, I got an error. Here is the traceback:
Traceback (most recent call last): File "/private/var/mobile/Containers/Shared/AppGroup/05D14C00-CCAC-4E98-A3CC-96C6944B8534/Pythonista3/Documents/outline.py", line 3199, in tableview_cell_for_row v = MyInputAccessoryView(row) File "/private/var/mobile/Containers/Shared/AppGroup/05D14C00-CCAC-4E98-A3CC-96C6944B8534/Pythonista3/Documents/outline.py", line 476, in __init__ self.width = mv.get_screen_size()[0] # width of keyboard = screen File "/private/var/mobile/Containers/Shared/AppGroup/05D14C00-CCAC-4E98-A3CC-96C6944B8534/Pythonista3/Documents/outline.py", line 1132, in get_screen_size app = UIApplication.sharedApplication().keyWindow() File "/var/containers/Bundle/Application/8778D1CF-1C08-48BA-9714-9D2CFE524EA1/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/objc_util.py", line 801, in __call__ ordered_args = list(args) + [kwargs[key] for key in kwarg_order] TypeError: 'builtin_function_or_method' object is not iterable
-
@ihf said
Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/05D14C00-CCAC-4E98-A3CC-96C6944B8534/Pythonista3/Documents/outline.py", line 3199, in tableview_cell_for_row
v = MyInputAccessoryView(row)
File "/private/var/mobile/Containers/Shared/AppGroup/05D14C00-CCAC-4E98-A3CC-96C6944B8534/Pythonista3/Documents/outline.py", line 476, in init
self.width = mv.get_screen_size()[0] # width of keyboard = screen
File "/private/var/mobile/Containers/Shared/AppGroup/05D14C00-CCAC-4E98-A3CC-96C6944B8534/Pythonista3/Documents/outline.py", line 1132, in get_screen_size
app = UIApplication.sharedApplication().keyWindow()
File "/var/containers/Bundle/Application/8778D1CF-1C08-48BA-9714-9D2CFE524EA1/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/site-packages/objc_util.py", line 801, in call
ordered_args = list(args) + [kwargs[key] for key in kwarg_order]
TypeError: 'builtin_function_or_method' object is not iterableI already got that, not reproductible. Not in my code. I personally think that Pythonista has a lot of problems with iOS/ObjectiveC next versions. Sorry for you, but one more time, I think it is not in my hands.
-
@cvp I am not sure what to make of this but I am testing on an iPad and the auto update does not seem to work properly. When I start the script it tells me there is a new version and asks whether I want to update. I say yes and it comes back and says the update was done and to restart the program and I restart it as I do on my other devices. However the update does not seem to take and it goes through the same cycle again. This happened with the previous release and I thought that I would just do a manual update to 1.20 but it is now happening again with 1.21. It’s obviously not a big deal as I can always do the manual update but I thought I would mention it.
-
@ihf said
I am not sure what to make of this but I am testing on an iPad and the auto update does not seem to work properly. When I start the script it tells me there is a new version and asks whether I want to update. I say yes and it comes back and says the update was done and to restart the program and I restart it as I do on my other devices. However the update does not seem to take and it goes through the same cycle again. This happened with the previous release and I thought that I would just do a manual update to 1.20 but it is now happening again with 1.21. It’s obviously not a big deal as I can always do the manual update but I thought I would mention it.
Is your outline.py local or on iCloud, I got tHe same problem, only once, but my script is on iCloud and download from GitHub to iCloud was done but perhaps not yet to your local device.
If your script is in your local Pythonista, was it edited in a Pythonista tab or run from a shortcut?
When you restart, do you remove Pythonista from memory first? If no, not sure Pythonista does not have a cache.It is always better to remove it from memory because if the script changes in some created ObjectiveC classes, they are not replaced without restarting Pythonista it-self.
Are you waiting some time before to restart?
-
@cvp I have 2 iPads and on the old iPad Pro, the auto update always works. (I run Outline.py that is in a tab, it asks if I want to download, I say yes, and I get a message saying the download completed and I restart the program. After I restart I am running the new version (I don't even have to quit Pythonista, just the script). On the newer iPad, I do the same exact thing except that when I restart the program it has not been updated. Weird.
-
@ihf The only difference I could see between your two devices is their speed, if you are running really on the two devices an edited script. I thought you used a shortcut to start the Pythonista script via its url scheme, and in this case you may run a not edited script.
You did not answer if the script is stored in iCloud or in a local folder. If it is in iCloud, the first device which will download the new version from GitHub to an iCloud folder would have done the job for the second device.
Anyway, I would prefer that you don't restart the script without restarting Pythonista it-self becuse, as explained in my previous post, if the new version changes code of a created ObjectiveC class, you need to restart Pythonista to use the updated code. -
@cvp The script is local on both devices and the outlines are on iCloud. On the newer iPad Pro, watch time I run v 1.20 it says that v1.21 is available and then says it is downloaded and after I restart the script, it repeats. Restarting Pythonista does not help.
-
@ihf do you use on your boTh devices the outline.py script in a Pythonista tab or do you use a shortcut to run the script? I could understand that Pythonista has problems to replace an edited running script, although on my iPad I don't have any problem. Sorry, but I am completely in the fog.
My code to replace the running script by a new one is
url = 'https://raw.githubusercontent.com/cvpe/Pythonista-scripts/master/Gists/outline.py' data = requests.get(url).content with open('outline.py', mode='wb') as out_file: out_file.write(data) del data
But if I set an un existing url, the code runs without error and thus does not replace the script.
Perhaps does the problem come from this. -
@cvp the running outline script is in a tab. I had wondered about replacing a running script but it works just fine on the iPhone and the (older) iPad.
-
@ihf said
the running outline script is in a tab. I had wondered about replacing a running script but it works just fine on the iPhone and the (older) iPad.
I'm sincerely sorry, but I don't understand why this difference exists
-
@cvp have you considered using the editor module to make sure the current file isn't open, and close it if it is?
Also, stupid question, but is it possible that @ihf has two copies of the script, and is running the old version? Or a version in site-packages, etc?
Seems like you could also do a check of current file to check if that is the one to replace. -
https://github.com/omz/Pythonista-Issues/issues/510
Also, someone had a cool idea to do this'
https://forum.omz-software.com/topic/5756/close-editor-tab -
@JonB said
have you considered using the editor module to make sure the current file isn't open, and close it if it is?
Also, stupid question, but is it possible that @ihf has two copies of the script, and is running the old version? Or a version in site-packages, etc?
Seems like you could also do a check of current file to check if that is the one to replace.First: you never ask stupid questions, believe me.
A lot of good ideas. I'll think about it. Thursday.
I had also thought to check if new downloaded version was really downloaded, as I saw that a bad url did not give an error to requests line.But that should not explain that it works on all my devices, on two of @ihf and not on his iPad Pro.
Thus perhaps your idea of two versions in this iPad Pro. Normally, my script displays its version at top than he can check the version, even if he has two copies. -
@JonB said
Also, someone had a cool idea to do this'
Wow. I write too much code, I completely forgot that. thanks
-
The key, I think is that a tab is open with the code. When you write to the tile, and read back from it, it will all look good. But once the script ends, or focus switches to the tab, it will re-write itself to the disk. So I think you must close the tab before writing to the file.
An alternative would also be to use the editor module to replace the code in the tab, if you detect that a tab is open with the file. I remember having to do something like that in that editor sideview project a long while back, or maybe in
git
.As an aside, I wonder if there is a way to gracefully shut down the script (closing the views, then getting rid of anything with the new ObjC classes, like input view controllers or whatever -- then always use the objc classes from their variable names, instead of string. E.g. you'd create the classes (using the debug option, so class gets number assigned to it if it already exists) then never refer to the class by it's string name, only the variable . That way new ObjC classes doesn't require a restart of the app.
-
... yes, it was git:
def refresh_editor(): #reload current file in editor # TODO: only reload if the file was recently updated... try: sel = editor.get_selection() editor.open_file(editor.get_path()) import time time.sleep(0.5) #let the file load editor.replace_text(sel[0], sel[0], '') #force scroll editor.set_selection(sel[0], sel[1]) except: print('Could not refresh editor. continuing anyway')
I think I determined the issue only happens for the current tab -- any background tabs get checked and reloaded if needed already.
I'm not proud of that
sleep
, I'm sure there is another way to check state of the load, but I never dug into it. -