psychopy.app - the PsychoPy® application suite

This module contains everything needed to run and manage the wxPython PsychoPy® GUI application suite (e.g., Coder, Builder and Runner).

The functions presented here provide a simple interface to the PsychoPy® application instance and any frames associated with it. This interface is intended for unit testing the GUI and for developers wishing to extend it.

Overview

startApp([showSplash, testMode, safeMode])

Start the PsychoPy GUI.

quitApp()

Quit the running PsychoPy application instance.

isAppStarted()

Check if the GUI portion of PsychoPy is running.

getAppInstance()

Get a reference to the PsychoPyApp object.

getAppFrame(frameName)

Get the reference to one of PsychoPy's application frames.

Details

psychopy.app.startApp(showSplash=True, testMode=False, safeMode=False)[source]

Start the PsychoPy GUI.

This function is idempotent, where additional calls after the app starts will have no effect unless quitApp() was previously called. After this function returns, you can get the handle to the created PsychoPyApp instance by calling getAppInstance() (returns None otherwise).

Errors raised during initialization due to unhandled exceptions with respect to the GUI application are usually fatal. You can examine ‘last_app_load.log’ inside the ‘psychopy3’ user directory (specified by preference ‘userPrefsDir’) to see the traceback. After startup, unhandled exceptions will appear in a special dialog box that shows the error traceback and provides some means to recover their work. Regular logging messages will appear in the log file or GUI. We use a separate error dialog here is delineate errors occurring in the user’s experiment scripts and those of the application itself.

Parameters:
  • showSplash (bool) – Show the splash screen on start.

  • testMode (bool) – Must be True if creating an instance for unit testing.

  • safeMode (bool) – Start PsychoPy in safe-mode. If True, the GUI application will launch with without loading plugins.

psychopy.app.quitApp()[source]

Quit the running PsychoPy application instance.

Will have no effect if startApp() has not been called previously.

psychopy.app.isAppStarted()[source]

Check if the GUI portion of PsychoPy is running.

Returns:

True if the GUI is started else False.

Return type:

bool

psychopy.app.getAppInstance()[source]

Get a reference to the PsychoPyApp object.

This function will return None if PsychoPy has been imported as a library or the app has not been fully realized.

Returns:

Handle to the application instance. Returns None if the app has not been started yet or the PsychoPy is being used without a GUI.

Return type:

PsychoPyApp or None

Examples

Get the coder frame (if any):

import psychopy.app as app
coder = app.getAppInstance().coder
psychopy.app.getAppFrame(frameName)[source]

Get the reference to one of PsychoPy’s application frames. Returns None if the specified frame has not been fully realized yet or PsychoPy is not in GUI mode.

Parameters:

frameName (str) – Identifier for the frame to get a reference to. Valid names are ‘coder’, ‘builder’ or ‘runner’.

Returns:

Reference to the frame instance (i.e. CoderFrame, BuilderFrame or RunnerFrame). None is returned if the frame has not been created or the app is not running. May return a list if more than one window is opened.

Return type:

object or None


Back to top