| Reference | Downloads | Github

Mouse click on image to indicate choice

To simplify my question, I want the subjects to click on one of the two given images to indicate a choice. I defined two visual stimuli, display them, and the response is registered by mouse click on one of the stimuli.

image1 = visual.ImageStim(win = mywin, name = “image1”, image = “tropical3.jpg”, color = (1,1,1), size = [11,11], pos = (-15,4))
image2 = visual.ImageStim(win = mywin, image = “tropical4.jpg”, color = (1,1,1), size = [11,11],pos = (0,4))


if event.Mouse.isPressedIn(image1):
print (“yes”)

The error message is “TypeError: isPressedIn() missing 1 required positional argument: ‘shape’”. Would really appreciate any help on this. Thanks so much!

Hi, it seemed like you didn’t call flip() yet (in your case, mywin.flip()) after preparing the images.
My guess is that the images did not show on the screen and caused the error. Could you add mywin.flip() after drawing the stimuli to see it that fixes the problem?

Thanks for your quick response! I tried but I am still getting the same error message.

I cannot reproduce the error with the below snippet. Could you copy and paste the codes you used?

from psychopy import visual
from psychopy import event

# create a Window
win = visual.Window(size=(1920, 1080), units='pix', fullscr=True)
my_mouse = event.Mouse()
# draw a image
ok = visual.ImageStim(win, image='ok.png')

while True:
    if my_mouse.isPressedIn(ok):