I am creating some image components in code (instead of using builder’s gui icons). I do this to control draw order. Everything works fine but I am not able to turn that object from displaying in subsequent routines even when I do myobject.setAutoDraw(False) in the original routine. I couldn’t check out what is inside setAutoDraw though (it might be a binary?) , so I tried a flip(), to see if that would clear draw. But it didn’t. Any ideas?
The point of this is that the fixation cross is displayed over the image. This was important to get it working in the online version. However, that fixation continues to be drawn even in the next routine, which has its own images and needs no fixation cross.
I can’t get rid of the fixation cross. I tried turning off the auto draw in the ‘End Routine’ section like shown below.
Even a win.flip() redraws the fixation cross in future routines. What is the way that I can turn it off?
You need it to be in the ‘Every Frame’ section because otherwise the fixation cross does not appear over the image in the online version. This is a bug reported in psychopy. And forcing a setAutoDraw helps enforce the draw in every frame.
I always keep the image component at the top, then the fixation cross, and then the code component at the bottom in case the code is custom.
However, the order of drawing (by moving components around in the builder) is done correctly when running offline via builder. It is NOT followed when running online , even though the same offline version of it works fine in the builder.
I have to draw it per frame because each of these routines - begin, perframe, end are individual functions and anything that you define in them are in local scope (scope of the function) and lost after. This is why moving the fixation code out of the frame will not work and doesn’t.
You have an awesome crib sheet.
What you have suggest above, however, does not explain why the fixation cross is being drawn even when I have moved past the routine that does this. For example, if the next routine does not have anything to do with fixation cross, the fixation cross that was drawn with the setAutoDraw gets drawn in the middle of the screen.
It almost makes me think that setAutoDraw is stored in a list somewhere that keeps being drawn from , irrespective of the routine. Or something like that. Other than that, I cannot see a good reason for this happening.
Yes, ideally that is wise advise. However, the online version does not have a way to control draw order. Nor does it draw in order of appearance from top to down unlike builder which does. And hence, this workaround.
Is there a way to flush the draw calls after a routine?
You should be able to control draw order online (as I have done in my own experiments) if you create your objects in an earlier routine (which can be of short duration of start after the routine has been ended) and then set auto draw to true in Begin Routine in the desired order (and again on frames where the components are changed). Then set autodraw to False for all the code components in End Routine