Win.flip in Code Component

Hi everyone, I’m new on Psychopy and I’m still trying to figure it out the best way to do some stuffs. I’m currently trying to show 2 scenes with 6 gabor patches each one. (1 scene -> 2 seg blank -> 2 scene). I tried to add this code component:

stimuli,stimuli2 = gaborMaker()
    
for gabor in stimuli:
    gabor.draw()
win.flip()
core.wait(2)
win.flip()
core.wait(1)
for gabor in stimuli2:
    gabor.draw()
win.flip()
core.wait(2)

This works in desk, but doesn’t work in JS version. Checking the JS code I saw why, JS doesn’t allow these “win.flip” as easily as Python does. I guess the solution is creating the 6 gabors in the Builder, instead of Code Component and just use the Code Component to create the positions to finally “send them” to the Builder’s Grating Component. So, my question is hypoteticall, what can I do if sometime I need a variable amount of stimulies in each trial? I mean, now I just need 6, so I can create 6 gabor on the Builder, but what if that number change trought the trials? I can’t figure it out how to do it without use win.flip in a Code Component.

Thanks in advance

See Wake Carter’S crib sheet

Just don’t use win.flip.

Just don’t (in Python or JavaScript) if you are using Builder. There is an implicit win.flip() at the end of the Each Frame tab and additional flips or halting the process with waitKeys will confuse the Builder code.

Cheers Jens

1 Like

Thanks for your reply Jens.

So, it’s literally impossible make an experiment with components created dynamically in the code, isn’t?