Is it possible to use quicklook in an UI.View?
I use an ui.WebView to have a quicklook of some files extensions, like PDF, doc,docs, xls,xlsx,pps,ppt,MP3,MP4,mov..., but it does not support .pages, .numbers etc...
As console.quicklook support these files types, is it possible to use this feature in an ui.View?
If your script does "console.quicklook(file)", you are able to pinch the quicklook window, even to turn it and close it by pinching...
Could that be a way to include it in an ui.View?
there are a few objc classes that allow this... stay tuned...
I was confident you should find a way😇
But, please,don't spend to much time for that...
This is a very rough first cut -- doesnt properly scale things, provide browsing capability, etc, but for example shows the first page of pdfs.
In this example, the code generates a list of all non-py files in the folder and presents it in a view, you can scroll between items. For your application you would just set items to [nsurl(abspath)]
Unrelated, but this also has the start of a system to make custom ObjCClasses-es easier and more pythonic -- basically an objcclass decorator which automatically registers the ObjCClass (using an objcmethod decorator to flag which methods to include) and creates objc instances when the python instance is created.
Thanks for spending your time, but I think it's too complex for me, really.
I've tried but the script displays a gray empty sheet...
Thanks to you, I've discovered th QLPreviewController object, and I'm busy to read some infos.
@cvp since there may be some files that are not viewable, you will get some gray boxes, but you should be able to drag left/right to scroll through the items. Also, you should probably just set j.items =[nsurl(path_to_your_filename)].
@JonB Always a gray sheet🤕 But visible with Quicklook of Pythonista
file_path = os.path.expanduser('~/Documents/Avosdim - Pose Stpre occultant Velux.pdf') j.items = [nsurl(os.path.abspath(file_path))] print(j.items)
I've the same result if the file does not exist, thus perhaps is my code incorrect?
@JonB I can't get it to work...