How to display all images from a folder

Hello, everyone,
I’m starting with psychopy 3 for the first time so maybe my question is too basic but I’ve been trying to solve it all week and I haven’t been able to.
My goal is to create an experiment where images appear with a certain time interval between them. All the images are in a folder. Here is my script:

 from psychopy import core, visual
 import os

  myWin = visual.Window([1280,720], monitor="testMonitor")

  folderPath = 'C:\\Users\\Tony\\Pictures\\PRACTICO\\positivas\\' 
  test_images = []
  for file in os.listdir(folderPath):
  if file.lower().endswith(".jpg"):


  for i in range (5): #I put the number 5 because there are 5 images in the folder 

    stimulus = folderPath + test_images[i]

    stim= visual.ImageStim(myWin, image=stimulus)

When i try to run this i get the follow error:

AttributeError: ‘list’ object has no attribute '_setCurrent’

What am i doing wrong? I really appreciate everyone’s help

Here’s the part causing the error:


You want


[myWin] is a Python list object, with one single element in it - myWin. The .draw method doesn’t expect to be passed a list, just a Window instance.

As an aside, there is a simpler and more general solution for dealing with the file paths. You can use

 folderPath = 'C:\\Users\\Tony\\Pictures\\PRACTICO\\positivas' 


stimulus = os.path.join(folderPath, test_images[i])

os.path.join joins parts of a file path together, and does it using platformspecific separators. So you can use the function if you’re on a variant of Linux or on a Mac as well.

1 Like