Mouse Response: Experiment exits on click

I’m trying to build an experiment with a mouse response. There are two text fields that are automatically generated from the excel list. People hear a sound and have to click on one of the words.

So far that works, but once I test the experiment and click on one of the words, it exits. I’ve tried pretty much all the settings there are for the mouse response, without success.

This is the error message that I get:

    if obj.contains(mouse):
AttributeError: 'str' object has no attribute 'contains'

How can I get this to work?

1 Like

I think this may be that you have entered some clickable stimuli into the mouse component, and one or more of those clickable stimuli are a string, rather than a clickable object.

I don’t really understand what that means. How do I turns my strings into clickable objects?

If you can tell me what you have entered as a clickable object in the mouse properties, we can see what is happening.

Here’s what it looks like now:

option1 and option2 are also the names of the columns in the .csv from which the options are loaded. Does that help or do you need more information?

Yes, thanks. option1 and option2 are strings, imported from your conditions file. You can change this to the actual text components option_1 and option_2 (text components are objects) and you should be able to click the text on screen .

I tried that, but now I get this error:

AttributeError: 'TextStim' object has no attribute 'option_1'


That will be related to using ‘option_1’ in the store params field. You might instead want to store its name, so use name instead in the store params field, and the name of option_1 (or 2) will be stored.

Thanks! It seems to be working now! :slight_smile:

I get a similar error:

if obj.contains(resp_mouse):
AttributeError: ‘list’ object has no attribute ‘contains’

conditions.xlsx (8.4 KB)

Could you insert target_x without the quotation marks?

What version of Psychopy are you using? I think that was a bug with an earlier version of Psychopy. It might help to update to a newer version.

Psychopy3 v2021.1.2

Your issue should be fixed in v2021.1.3 if you remove the quotation marks. :+1:

Unfortunately, It did not help…

if obj.contains(resp_mouse):

AttributeError: ‘list’ object has no attribute ‘contains’


Which object are you referring to? Perhaps you mean
if target_x.contains(resp_mouse):

1 Like

Thank you for your help!
I tried to follow Tutorial 1: How to make a Posner in PsychoPy (2020); start at 10:00

I had a mistake, now I fixed it: in Clickable stimuli= target (not target_x from excel), however I get the same error…

if obj.contains(resp):
AttributeError: ‘list’ object has no attribute ‘contains’

I also tried to create a polygon…

However, I can not put “target_x” (title in excel) in pos (of cycle)
NameError: name ‘target_x’ is not defined

fig4 ![figure3|690x320]

Hello, I was wondering if you knew why this error happened?
I am getting the same error:

if obj.contains(mouse):
AttributeError: ‘list’ object has no attribute ‘contains’

I am making the corsi task in psychopy. It is working by itself, however when i add it to a group of 3 other tasks only the corsi seems not to work and i get that error. I have copied what i did exactly but cant seem to figure out why it ‘clashes’ with other tests…

Add a comma after the clickable stimulus in the mouse component.

Hello! I have commas after the clickable stimuli but i still get the same error unfortunately. I put a comma after the last clickable stimuli to see if that worked but that did not work either. I also tried adding a comma after ‘name’ and that did not work either

I have attached a screenshot to show this:

Try removing the quotes. You are referring to components not text