psychopy.iohub.util.ClearScreen

class psychopy.iohub.util.ClearScreen(experimentRuntime, eventTriggers=None, timeout=None, background_color=(255, 255, 255))

Bases: psychopy.iohub.util.visualUtil.ScreenState

__init__(experimentRuntime, eventTriggers=None, timeout=None, background_color=(255, 255, 255))

Methods

__init__(experimentRuntime[, eventTriggers, ...])
addEventTrigger(trigger)
build()
flip([text])
getCurrentScreenState()
getEventTriggers()
getStateStartTime()
sendMessage(text[, mtime])
setEventTriggers(triggers)
setScreenColor(rgbColor)
setTimeout(timeout)
switchTo([clearEvents, msg]) Switches to the screen state defined by the class instance.

Attributes

experimentRuntime
window
switchTo(clearEvents=True, msg=None)

Switches to the screen state defined by the class instance. The screen stim and built and a flip occurs.

Three conditions can cause the switchTo method to then return, based on whether a timeout and / or DeviceEventTriggers have been set with the Screen state when switchTo is called. In all cases a tuple of three values is returned, some elements of which may be None depending on what resulted in the state exit. The three conditions are:

  1. If no timeout or DeviceEventTriggers have been specified with the ScreenState, switchto() returns after the window.flip() with:

    (stateStartTime, None, None)
    

    where stateStartTime is the time the call to flip() returned.

  2. If a timeout has been specified, and that amount of time elapses from the startStartTime, then switchTo() returns with:

    (stateStartTime, stateDuration, None)
    

    where:

    • stateStartTime is the time the call to flip() returned.
    • stateDuration is the time switchTo() returned minus
    • stateStartTime; so it should be close to the timeout specified. It may be rounded to the next flip() time interval if something in the state is causing the screen to be updated each frame.
  3. If 1 - N DeviceEventTriggers have been set with the ScreenState, they are monitored to determine if any have triggered. If a DeviceEventTrigger has triggered, the triggering event and the triggers callback function are retrieved. The deviceEventTrigger is then reset, and the callback is called.

If a callback returns True, the ScreenState is exited, returning (stateStartTime, stateDuration, exitTriggeringEvent), where:

  • stateStartTime is the time the call to flip() returned.
  • stateDuration is the time switchTo() returned minus stateStartTime; so it should be close to the timeout specified. It may be rounded to the next flip() time interval if something in the state is causing the screen to be updated each frame.
  • exitTriggeringEvent is the Device event (in dict form) that caused the ScreenState to exit.

If the callback returns False, the ScreenState is not exited, and the the timeout period and DeviceEventTriggers cintinue to be checked.