Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exiting PsychoPy Window

I was stepping through some PsychoPy code in the coder view, and ran the Window function:

http://www.psychopy.org/api/visual/window.html

This had the helpful side-effect of opening a grey window and did not bind any keys to exit. How does one exit in this situation? I am on a Mac running Snow Leopard.

I tried to use the Finder (Command+Space) to open a terminal window and type killall psychopy but this was not effective. Maybe killall PsychoPy2 would have been more effective, but this is a pretty unfortunate way to kill an errant PsychoPy process - especially when you can't see if you have opened a terminal window and if you are typing. Is there a secret keystroke combination that will always release PsychoPy's hold on the screen?

like image 426
alexplanation Avatar asked Oct 20 '22 20:10

alexplanation


1 Answers

There is not a magic keypress that will always work for closing a window or escaping from a process. I highly recommend developing your experiment with fullscr=False, and then changing to fullscr=True in the final stages and for running subjects. (This switch is in Builder > Experiment settings > Screen > Full-screen Window -- uncheck to box, or the fullscr=False parameter when creating a Window instance in code.) Its much easier to switch back and forth and close zombie windows if you are not in full-screen mode.

In the Builder, the 'escape' key often will work like a magic key, but only because some code generated by the Builder specifically listens for the 'escape' key and will bail out if it gets one. (Compile a Builder script and check out the code!). Note that there is an Experiment setting which allows you to disable escape, so even this is not guaranteed to work.

From the Coder, if you make a 2-line program like this and run, it will shut the window itself when it ends:

from psychopy import visual
w = visual.Window()

Putting core.quit() somewhere in the code will have the same effect as the script ending at the end (i.e., the window will close down fine).

If you have a window already created, you can close it without quitting PsychoPy, but you have to know how to refer to that window instance and tell it to close() -- w1 in the example below:

from psychopy import visual
w1 = visual.Window()
w1.close()
# do other things here, perhaps a GUI
w2 = visual.Window()  # another, new window pops open

Multiple windows closing and reopening is not common usage--if you find yourself doing it, there's probably a better way. But it does illustrate how to close a window.

like image 59
jrgray Avatar answered Oct 23 '22 11:10

jrgray