Using psychopy from a gui ... how to stop psychopy

283 views
Skip to first unread message

Jason Steffener

unread,
Jan 12, 2016, 4:33:02 PM1/12/16
to psychopy-users
Hello.
I wrote a GUI to launch all of my psychopy experiments.
The gui uses Tkinter and is simply a bunch of buttons which each launch my psychopy experiment.

If my experiment is running and I press "escape" my experiment window closes as well as my GUI window.

I would like to keep my GUI window open, I therefore removed the core.quit() function from the code piece:

# check for quit (the Esc key)
            if endExpNow or event.getKeys(keyList=["escape"]):
                win.close()
                # core.quit()

But with this the experiment keeps running but with no window!

Can I press escape and have my experiment stop and its window close but NOT my GUI?

Thank you for feedback.
Jason

Jeremy Gray

unread,
Jan 12, 2016, 4:54:46 PM1/12/16
to psychop...@googlegroups.com
Check out how coder.py and builder.py launch experiment scripts. That will probably work for you too.

--Jeremy

--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/195151d2-503f-41b6-8d47-8c2e45d141f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jason Steffener

unread,
Jan 12, 2016, 9:22:47 PM1/12/16
to psychopy-users
I figured it out using sys.exit()

# check for quit (the Esc key)
            if endExpNow or event.getKeys(keyList=["escape"]):
                win.close()
                sys.exit()

Thanks for the clues Jeremy.

Jason

Michael MacAskill

unread,
Jan 13, 2016, 12:20:30 AM1/13/16
to <psychopy-users@googlegroups.com>
Hi Jason,

I think core.quit() does some PsychoPy housework before exiting (e.g. ensuring all data saving is completed, files closed etc). You might want to check that you aren't missing out on any of that (probably less of an issue if you are writing your own experiments rather than using Builder, but still…)

Regards,

Michael


> On 13/01/2016, at 15:22, Jason Steffener <stef...@gmail.com> wrote:
>
> I figured it out using sys.exit()
>
> # check for quit (the Esc key)
> if endExpNow or event.getKeys(keyList=["escape"]):
> win.close()
> sys.exit()
>
> Thanks for the clues Jeremy.
>
> Jason

--
Michael R. MacAskill, PhD 66 Stewart St
Research Director, Christchurch 8011
New Zealand Brain Research Institute NEW ZEALAND

Senior Research Fellow, michael....@nzbri.org
Te Whare Wānanga o Otāgo, Otautahi Ph: +64 3 3786 072
University of Otago, Christchurch http://www.nzbri.org/macaskill

Reply all
Reply to author
Forward
0 new messages