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.
How to quit scene and continue?
-
I have a module that takes some parameters and downloads some files from the internet - weather maps in fact. I wrote it years ago - it ran under maemo.
My wife bought an iPad and I wrote a wrapper for it in pythonista. It gets the parameters using console.input_alert, then calls the download module, and then displays the maps in a webbrowser window.
I bought an Android device. I ported the iPad version to that. I recently wrote a GUI for the parameter-entry; most of the parameters stay the same as the last time and the one that doesn't, a date, can usually be predicted. So it's a waste of time to prompt for all these paramters. Here's some pictures of the result here, which will give you an idea of what I'm trying to do:
<a href="http://www.flickr.com/photos/7544154@N07/9946566726/">GUI</a>
<a href="http://www.flickr.com/photos/7544154@N07/9946631744/">Viewer in the browser</a>So I thought I'd update the iPad version to do something similar. I was half-way though producing a similar GUI using scene, which works fine I think so far, when I realised that unlike on my Android version there appears to be no scene.quit(). I want to resume with the code after the run()
Can you quit scene and continue? I want further output in the log window.
The download module uses print to display progress and error messages. I don't really want to move all that into the GUI - I've done something similar with Tkinter and it's a pain. And I certainly can't implement my viewer in scene.
-
The way that Scenes get launched is really strange in the current Pythonista. See the gist at the end of http://omz-software.com/pythonista/forums/discussion/169/correct-way-to-do-threading-in-pythonista#Item_10
-
Thanks for that. I know nothing about threads in python, but I get the gist. I'l read up on it.
It helps explain something that was puzzling me but I hadn't got round to investigating. Immediately after the run() I have a print statement - it prints the parameters (they're global). On the Android version that get executed after I quit the GUI. But in pythonista it executes <i>before</i> running the scene - and prints the parameters going <i>into</i> the GUI.
But below that is an import that fails in pythonista, because the module name is wrong and I haven't yet corrected it. That statement fails only after I close the scene with the X at the corner.
I suppose that what's happening is that it takes some time to launch the scene, time enough to print but not enough to reach the import. Which suggests a solution: insert a delay after the run(), get the parameters in the scene, then close it with the X.
A bit of a kludge. I could make a friendly green arrow pointing to the X labelled 'Download'.
-
No. My theory is wrong. The main module, which has run(myscene()) in the <i>middle</i> of it, completes before calling the scene . If I correct that import statement it downloads the weather maps, using the default parameters, and only switches to the scene once it reaches the webbrowser.open command at the end. (And it doesn't open the webbrowser window at all.)
So to enable this scene to collect parameters I need to move all the code after the run(myscene()) somewhere else so that it runs after the scene.