Gives an error at the line that I marked.
# coding: utf-8 import ui import appex import Image v = ui.load_view() img = appex.get_image() if img: v["image"].image = ui.Image(str(img)) #Error occurs here, it says IOError couldn't display image or something like that v.present('sheet') if not img: v.close()
How do I correct it? Please help!
I don't know why you get that error, but try
That did it for me :/
Oh, and remove the
imgon the line you get the error
appex.get_image()had issues that are now fixed in the current beta... See https://forum.omz-software.com/topic/3498/error-when-trying-to-get-a-photo-attachment-in-a-mail and https://github.com/omz/Pythonista-Issues/issues/169
I think the main problem here is that
PIL.Image, but the
ui.Imageconstructor expects an image name or file path...
Something like this should work (it's possible that workarounds are needed for the App Store version of Pythonista 3 because of the aforementioned bug in
img_data = appex.get_image_data() if img_data: v['image'].image = ui.Image.from_data(img_data) # ...
Thanks a lot! THAT WORKS!!! Without you I could have wasted time on trying to correct this error!