Calling console.quicklook() on a UI button action?
In my program I have a GUI with a button which, when pressed, is supposed to bring up a Quick Look of a particular file. I decorated the button function with @ui.in_background and yet when the button is pressed, no Quick Look view pops up. On the first press, nothing happens and on the second press Pythonista as a whole hangs and needs to be force-closed via the app switcher. An example is the following, where the pyui file just contains a single button whose action references the button function.
# coding: utf-8 import ui import console @ui.in_background def button(sender): console.quicklook('file.ics') ui.load_view('Untitled 2').present('sheet')
TutorialDoctor last edited by
console.quicklook()needs a full file path as an argument. What is the path to the file?
The file is in the same directory as the script so that is the full path of the file. The statement works just fine when it's not called from a ui function or when it's called from the console, it's just something about being called via a button action that prevents it from working.
JonB last edited by
Short answer: you must close any ui views before running quicklook. Longer answer, you have to use ui.delay to make sure the view is finished hiding before calling quicklook. For actual code. See thread above.
Thank you, that worked brilliantly! Neither threading.Timer nor ui.delay were working properly; they just hung the program.<Br>
<Br>worked perfectly though.