psychopy.org | Reference | Downloads | Github

Best practice for starting a clock right after a call to win.flip()

Hi!

I have noticed two ways to start a clock after a win.flip() call on the forum, and I wonder if they are any different. First way:

myClock =core.Clock()
win.flip()
myClock.reset()

Blockquote

Second way:

myClock =core.Clock()
win.callOnFlip(myClock.reset) 
win.flip()

Thank you!

1 Like

I suspect that they will be almost indistinguishable in practice when writing your own code from scratch.

But the .callOnFlip() method is particularly useful in Builder-generated code, as you don’t have direct access via code components to insert a line of code exactly following the win.flip() operation. i.e. the win.flip() happens somewhere deep in the script, which might be some distance from the code inserted in the “each frame” tab of a code component.

PS please don’t quote your code with > symbols in this forum. It stops the proper highlight and indentation taking effect. Just surround your code snippets in triple backticks (i.e. ```) before and after.

1 Like