PsychoPy window freezes after running the script from Spyder on mac OS X El Capitan Version 10.11.4

I run PsychoPy code from Spyder, an editor for Python. I am working on a mac OS X El Capitan Version 10.11.4. The experiment runs, but when it ends the window freezes and I have to force quit it. I also tried to use fullscr=False and a very low size for the window, but I still have the problem.
I am an absolute beginner, so I don’t know what to do anymore. Thank you for your help!

For example, I have the problem when I run this code:

from psychopy.visual import Window, TextStim
from psychopy.core import wait

DISPSIZE = (800,600)
FGC = (-1,-1,-1)
BGC = (1,1,1)

win =Window(size = DISPSIZE, units=‘pix’, fullscr=False, color = BGC)
fix = TextStim(win,text=’+’,color = FGC, height = 30)
prime = TextStim(win,text=‘LOVE’,color = FGC, height = 30)
mask = TextStim(win,text=’####’,color = FGC, height = 30)
target = TextStim(win,text=‘BLUR’,color = FGC, height = 30)

fix.draw()
win.flip()
wait(1.2)

prime.draw()
win.flip()
wait(0.032)

mask.draw()
win.flip()
wait(0.1)

target.draw()
win.flip()
wait(1)

win.flip()
wait(1)

Hi @mansu,

Have you downloaded the standalone version of Psychopy from http://www.psychopy.org/, and tried running your code from this build?

Thank you @dvbridges! If I do like you said, it does not freeze. Anyway, in my class they want me to use it from Spider. I wonder why from Spyder it doesn’t work and from the standalone Psychopy yes.

I don’t know exactly what you mean by “freeze,” but if you want the window to go away at the end of the script then you can close it using it’s close function, which is not invoked at the end of the code snippet you posted.

Not sure how Spyder works, but it if leaves the Python interpreter running which executes that script after the script ends then the window would stay open. If you experienced something different in another IDE, it would be because that IDE exits the interpreter after the script completes, freeing (and therefore closing) the window instance when it does that.

-Allen

2 Likes

Thank you @AllenIngling. The problem, as you suggested, was that I didn’t use the close function. Again thank you very much for your answer!