Forum Archive

Images not loading in ui.imageview()

donnieh

Loading an image from the local library works fine. See code below.

​
import ui
import Image
sv = ui.ScrollView()
sv.background_color = 'gray'
iv = ui.ImageView()
iv.image = ui.Image.named('Test_Bridge')
sv.add_subview(iv)
sv.present()

But when I add my own image from the camera roll it does not work. What needs to be done to load a custom image?

I open my photo album and copy the photo to clipboard using share menu. I then add the photo to Pythonista using the insert option. I can see it in the My Images category in Pythonista. It just wont load in for some reason.

​
import ui
import Image
sv = ui.ScrollView()
sv.background_color = 'gray'
iv = ui.ImageView()
iv.image = ui.Image.named('_Image_1') #does not work
#iv.image = ui.Image.named('_Image_1.PNG') does not work
#iv.image = ui.Image.named('_Image_1.png') does not work
#iv.image = ui.Image.named('_Image_1.JPG') does not work
#iv.image = ui.Image.named('_Image_1.jpg') does not work
sv.add_subview(iv)
sv.present()

I am using Pythonista 1.5 on iOS9 - iPhone 6+

ccc

Use http://omz-software.com/pythonista/docs/ios/photos.html to access the camera roll.

donnieh

I may not have spoken clearly. The goal here is to put a custom image in an imageview(). The camera roll is just a place where I am getting my images from to put into pythonista.

ccc

See image_file.py at https://github.com/cclauss/Ten-lines-or-less

donnieh

Thank you @ccc