Forum Archive

Problems with ui.imageview

tomkirn

Hi,

I have some trouble with ui.imageview. Trying to set an image I cannot display images from 'My Images'. Choosing an image from Emojis or Test Images works fine.

view['imageview1'].image = ui.Image.named('_Mauzi')

Some hints?

Regards
Tom

omz

The "My Images" feature is mostly intended for use with the scene module, and to be honest, I haven't really touched it since version 1.0 – I'd really like to replace it with something better...
Anyway, you can use it with the ui module like this:

view['imageview1'].image = ui.Image.named('Images/_Mauzi.png')

This only works if your script is in the root folder of the script library. If that's not the case, try something like this:

import os
images_root = os.path.expanduser('~/Documents/Images')
image_name = '_Mauzi'
image_path = os.path.join(images_root, image_name + '.png')
view['imageview1'].image = ui.Image.named(image_path))
tomkirn

Many thanks, now it works fine.