AttributeError: 'str' on clickable stimuli

OS (e.g. Win10): Mac M1
PsychoPy version (e.g. 1.84.x): 2021.2.3
Standard Standalone? (y/n) If not then what?:
What are you trying to achieve?:. I’m building an experiment where images pop on the screen one at a time and the response has to be made by mouse or touch.

What did you try to make it work?:
I have a condition file with - image column to present the images in spatial order and a valid column for reference of valid click.

What specifically went wrong when you tried that?: the image is present but the mouse click is not working. Exp ends with attribute error.

Include pasted full error message if possible. “That didn’t work” is not enough information.

There is an [ AttributeError: ‘str’ object has no attribute ‘contains’ ], How to fix this?

if obj.contains(click_response):
AttributeError: ‘str’ object has no attribute ‘contains’

Experiment ended.

Is image the name of the image component or a column in your spreadsheet?

“image,” is the name of the column in my spreadsheet. I put the clickable stimuli as “image,” because I want the responses for all images that appear from that column.

You need to put the name of the image component that shows image rather than the file name, which is a string.

Also, if you move online, you will probably need to use a different name for your variable – but it should be fine locally.

The name of the image component here was ‘target’, when I put that in clickable stimuli, it worked :slight_smile: Thank you very much!!
I’m also curious to know more about your suggestions for a change of the variable name if I push it online. Why is that?

Thanks

Here’s a quote from my crib sheet.

Don’t Use simple terms for variables, since they may already be in use by PsychoPy. Variable names to avoid are: class, core, image, index, Length, list, Object, Number, round, sound, Symbol, t, thisTrial, trials, util, visual.

I see, thanks for sharing this fabulous g-doc! Very helpful!.