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.
console.quicklook freezing app
-
I'm building an app that uses the ui module to perform some calculations, display the results, and optionally export a PDF produced with reportlab. Everything works perfectly up to the point of displaying the newly created PDF. My export buttons action looks like this:
@ui.in_background def export(sender): ... ... file_path = create_report() #Creates PDF and returns path console.quicklook(file_path)
The app freezes and I have to close pythonista to get back in. I tried using a console.alert, thinking I wasn't using ui.in_background correctly, and that worked fine. I can also verify that the path being returned is correct. Any ideas?
-
How are you presenting your view? As a fullscreen, panel, popover, sheet, etc?
I reproduced with a sheet, but panel worked.
-
Ok, the workaround for all present types is that you need to close the view first, wait for it to close, then launch quicklook. If you want, in delayed function that launches quicklook you could relaunch the view, so it pops up when the (blocking) quicklook is done. See example below.
I used threading.Timer here, but most likely ui.delay would also work (I feel like I've had problems where ui.delay didn't work, but Timer did, but I could be imagining that). I didn't have a PDF handy, so tested it on a jpg I had lying around, but I was able to reproduce the crash, so this method should work.
import ui,console from threading import Timer v=ui.View() b=ui.Button() b.title='quicklook' b.frame=(10,10,100,100) b.bg_color=(1,0,0) global presentType presentType = 'fullscreen' #tried all styles, they all work def a(sender): sender.superview.close() #first, close view. def QL(): global presentType #wrapper to open quicklook, then reopen view after console.quicklook('screen15.jpg') #happens to be only image i have lying ariund sender.superview.present(presentType) Timer(1,QL).start() #give view time to close. 0.5 sec crashed on my ipad2 b.action=a v.add_subview(b) v.present(presentType)
-
Okay, so I got this to work using ui.delay, however, then I see the console for a second inbetween the view closing and the PDF opening, and the same thing when I close the PDF. Supposing I export this app, what will the user see?