I’d like to show two rating scales that should remain on the screen until subjects respond. First I show rs1 and save a screenshot. Then I show this screenshot and rs2. The code below works for the first trial, but not for the second trial since rs1 disappears when rs2 is presented. What is the reason for this?
Thanks,
Max
from psychopy import visual
win = visual.Window()
rs1 = visual.RatingScale(win,choices=['True','False'],marker='hover',singleClick=True, pos=(0,0))
rs2 = visual.RatingScale(win,singleClick=True, pos=(0,-0.5))
for t in [1,2]:
rs1.reset()
rs2.reset()
while rs1.noResponse:
rs1.draw()
win.flip()
screenshot=visual.BufferImageStim(win,buffer='front')
while rs2.noResponse:
screenshot.draw()
rs2.draw()
win.flip()
win.close()
this may not be a direct answer to why the screenshot disappears (I am having issues even getting screenshots on my system!), but a much easier way to do this would be to just draw the scale rs1 again.
RatingScale has a parameter called “disappear”, which by default is False. If after you’ve taken a rating you just draw it again, it will not accept new ratings and instead show the previous choice. so this should work for you:
from psychopy import visual
win = visual.Window()
rs1 = visual.RatingScale(
win, choices=['True', 'False'], marker='hover', singleClick=True, pos=(0, 0))
rs2 = visual.RatingScale(win, singleClick=True, pos=(0, -0.5))
for t in [1, 2]:
rs1.reset()
rs2.reset()
while rs1.noResponse:
rs1.draw()
win.flip()
while rs2.noResponse:
rs1.draw()
rs2.draw()
win.flip()
win.close()
Jan is right, but you could achieve what you want by writing just one while loop, one way it would be the following:
from psychopy import visual, core
win = visual.Window()
rs1 = visual.RatingScale(win,choices=['True','False'], marker='hover', singleClick=True, pos=(0,0))
rs2 = visual.RatingScale(win, singleClick=True, pos=(0,-0.5))
for t in [1,2,3]:
rs1.reset()
rs2.reset()
while rs2.noResponse:
rs1.draw()
if not rs1.noResponse:
rs2.draw()
win.flip()
# just allow ~500 ms of empty screen between trials
win.flip()
core.wait(.5)
win.close()
I’m glad I could help, I inserted the 500 ms gray screen there just to see better the behavior of the scales between trials, you don’t have to use it.
Best,