from psychopy import visual, event

def wait_for_space(screen, text="press SPACE"):
    instruction = visual.TextStim(screen, text=text, color='white')
    instruction.draw()
    screen.flip()
    print("Waiting for space bar...")
    event.waitKeys(keyList=['space'])