Change opacity of the shape to reveal the text on mouse click

I need to reveal the text under an image with a mouse click. What are the steps to change the opacity of the shape on click that covers the text in Builder (or in Code, though I am a novice)?

**OS Win11
**PsychoPy version 2022.2.4

Hi @Dasha_Mesquita,

if you have an image component image_stim and a mouse component mouse, you can add a code component to your routine and have

Each frame

if mouse.isPressedIn(image_stim):
    image_stim.opacity = 0
1 Like

@ajus, I did what you suggested and had this error. Do you have any idea what it means and what to do with this?

Traceback (most recent call last):
File “C:\Users\dasha\Documents\PsychoPy_TESTS_for PhD\LLAMA\untitled_LLAMA_B_lastrun.py”, line 116, in
trials_LLAMA_B = data.TrialHandler(nReps=None, method=‘random’,
File “C:\Program Files\PsychoPy\lib\site-packages\psychopy\data\trial.py”, line 147, in init
self.nReps = int(nReps)
TypeError: int() argument must be a string, a bytes-like object or a number, not ‘NoneType’
################# Experiment ended with exit code 1 [pid:3864] #################
709.4300 EXP Imported C:/Users/dasha/Documents/PsychoPy_TESTS_for PhD/LLAMA/Llama_B_test.xlsx as conditions, 20 conditions, 3 params
709.4327 INFO Loaded monitor calibration from [‘2022_10_17 10:29’]

This seems to have nothing to do with the code. In your loop “trials_LLAMA_B” the nReps field seems to be empty. It must contain the number of repetitions you need.

2 Likes

Thank you so much! I fixed it and everything is working!)) I was wondering if you could help me with another question. I tried to find the solution online but I am not even sure how to formulate my question)
I want people to click, see a word for several seconds, then the word disappears, and to see it again a person needs to click once more.

I forgot to add, that I need to have several clickable images on the screen. (maybe that is important)

So the timeline would be: I click an image, and it disappears to reveal a text. After some time (how long?) the text disappears, I click again (where?), and the text reappears. Right?

How should it work with different images? Can I click all images? Or just one? Do they all do the same thing independently from another?