Search code examples
pythonpsychopy

Python psychopy imageStim


I'm using psychopy to get an image on a window like this:

from psychopy import visual
window = visual.Window(size= (1000,600), units = 'pix', pos = (10,10))
stimulusimage = ('C:\Users\name\Documents\Python Scripts\Project\stimuli\Visual Stimuli\Positive\1.jpg')
showingimage = visual.ImageStim(window, image=stimulusimage)
window.flip()

I don't see an image on the window and I have no idea what I'm doing wrong, I don't get any error message.


Solution

  • You need to draw the image before you flip the window:

    showingimage.draw()
    window.flip()
    

    Otherwise it will show a blank screen. By the way, you need not put the filename in parentheses.