Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Selecting images randomly from file pool

Hi all,

I was trying to display images randomly on a canvas on OpenSesame. I want to do this using the inline script. Specifically, I added some images manually from a local repository to the file pool in OpenSesame. I now want to display all of these images in random order on a new canvas in a loop.
I found the following piece of code on the OpenSesame website:

"""
if u'img.png' in pool:
print(u'img.png could not be found!')
else:
image_path = pool[u'img.png']
my_canvas = canvas()
my_canvas.image(image_path)
my_canvas.show()
"""

I tried using the above code to display one image from my file pool on a canvas but I got an error as follows: "NameError: name 'pool' is not defined". Maybe I'm missing something basic so I'd appreciate help in sorting this out!
My experiment file is in the same folder as the file pool images.

Thank you for your help in advance.

Anupama

Sign In or Register to comment.