psychopy.org | Reference | Downloads | Github

How to remove a visual.<stim>

Working on a project for a team that is using PsychoPy, looked through documentation and cannot find a way to delete/remove a stim that is currently visible.

The reason for this is we’re tasked to create various “scenes” with test being displayed in-between certain points of user input.

My idea was to use a few visuals stims to display the message, then delete that to show case the next “scene”.

If you refresh the screen (win.flip()) without drawing your visual stimulus, it should automatically “disappear” from the screen (unless you specified autoDraw = True, in which case you need to set it to False). You can then later make it reappear by using the stimulus.draw() method before using win.flip().

Is this what you meant?

There’s more information on this process here:
http://www.psychopy.org/coder/codeStimuli.html

To use the example from the psychopy documentations and removing the images at the end:

from psychopy import visual, core
win = visual.Window([400,400])
message = visual.TextStim(win, text='hello')
message.setAutoDraw(False)  # Do not draw automatically
message.daw()  # draw text
win.flip()
core.wait(2.0)
message.setText('world')  # change properties of existing stim
message.draw()  # draw again
win.flip()
core.wait(2.0)
win.flip()  # flip without drawing
core.wait(2.0)