Display image after button is pressed

Hi everyone

I’m trying to add a button that makes an image appear when it is pressed. This is probably a pretty simple thing, but since I’m a beginner in PsychoPy (and Python), I’m stuck on what to put in the image component at start $condition. I suppose I need to enter button.callback and define that function in the button component but I don’t know what to enter there.

Thanks for your help and let me know if you need more information on my experiment.

Button callback doesn’t yet work online, but it has been fixed for the first 2025 release. It’s possible that it might work in 2024.2.5. However, you could try this method locally.

Code component Begin Routine tab

showImage = False

Button Callback

showImage = True

Image start condition

showImage

Have a try with this and see if it does what you want. If necessary there is some code that could be added to Each Frame to make it work without button callback.

Hi

Thanks for the fast reply. It works perfect, both locally and online!

What version of PsychoPy did you use?

It is 2024.2.4

Cool. Maybe the scope issue doesn’t matter in this case because you don’t need to check the value of showImage later.