PsychoPy version
2020.1.2
Standard Standalone?
Yes.
What are you trying to achieve?:
I have three image components in a trial routine inside of a loop, which get images from different files. For some trials, I only want two of the image components to be drawn, while the third one should not be drawn.
What did you try to make it work?:
I added a code snippet and in the ‘Begin Routine’ tab, I added:
if my_condition:
myImageComponent.setAutoDraw(False)
What specifically went wrong when you tried that?:
The component is still being drawn. I can see in the generated code that the Builder adds this bit, after the section where the ‘Begin Routine’ code is run:
if myImageComponent.status == NOT_STARTED and tThisFlip >= 0.0-frameTolerance:
# [...]
myImageComponent.setAutoDraw(True)
So the Builder’s automatically generated code overrides what I want to do.
Possible not-great solutions
I could skip adding the image Component using the Builder entirely, and instead create it “manually” in the ‘Begin Experiment’ tab. But the experiment is already fairly complicated so if possible I want to avoid this additional code, to increase readability for colleagues who are less knowledgeable in Python.
I could also have a completely blank (same color as background) image file that I would use for trials where the image should be invisible, but that seems pretty convoluted.
So, does anyone know a clean method for temporarily “hiding”/disabling image components? I feel like I’m missing something basic.