Forum Archive

Loading images into gui.

Vertec

How do I go about loading images into a pythonista ui from photo roll.

The purpose is just to have my own profile logo in the corner of my scripts.

I can load the library images but I can't seem to get a photo roll image into the library or load from my own file path within pythonista

jbap

Try using ui.ImageView; it takes an image from PIL.Image.open() and if presented, displays it

Vertec

I'm still having trouble with this. I just want to use an image already sitting in the images folder in pythonista.

omz

Assuming your image file is in the same folder as your script, you can load it into an image view like this:

my_image_view.image = ui.Image.named('image.png')

(jpeg would also work, of course.)

chibill

I have a question that is about the same topic.

Say I want to load an image from StringIO of the image data. (The data was retrieved from a MC server status) how would I do that. I have tried setting ImageView.image to a PIL Image but it errors saying it wants a type ui.Image unlike what is documented in the help for ui.ImageView

heyguy4

@omz Whenever I try that, I get an error that says "Expected a texture object".