Minimize/maximize psychopy window to perform eyetracker calibration

Hi everyone,

I am using Psychopy version 2020.1.3 on a Windows 10 machine. What I am trying to achieve is to minimize/maximize the psychopy window every time I need to calibrate the eye tracker. To experiment with this I have created a demo task (without eye-tracking) with two routines (1st routine contains a ‘Start’ text component and 2nd routine an ‘End’ text component). In the first routine there is also a code component with the below code in the each frame tab:

if event.getKeys(keyList=['l',]):
    win.winHandle.minimize()
    win.winHandle.set_fullscreen(False)
    win.flip()
elif event.getKeys(keyList=['b',]):
    win.winHandle.maximize()
    win.winHandle.set_fullscreen(True) 
    win.winHandle.activate()
    win.flip()
elif event.getKeys(keyList=['k',]):
    continueRoutine=False

With this code, I am able to minimize/maximize the psychopy window or proceed to the next routine using a specific letter. It works fine.

However, when I use the exact same code in a demo task WITH eye-tracking, I have issues with maximizing and activating the psychopy window once I have performed the calibration. The minimization works fine, but when I press ‘b’ which is the letter I use to maximize/activate the psychopy window, it just doesn’t work.

I have tried all the things that are mentioned here python - PsychoPy reopen window - Stack Overflow but to no avail.

What I’m missing here? Thanks in advance for your help.

1 Like

This is what psychopy 2021.2.3 uses to minimize / maximize a window on Windows 10:

# minimize the PsychoPy window
win.winHandle.minimize() 
win.winHandle.set_fullscreen(False)
# maximize the PsychoPy window
win.winHandle.set_fullscreen(True)
win.winHandle.maximize()

After maximiizing the window you may need to (re)draw stim and flip before the window graphics are visible.

If you are running your own python env, pyglet 1.4.11 is needed on Windows. This functionailty seems to no longer work in the latest pyglet release.

This is only needed on Windows; macOS and Linux seem to handle showing the calibration window on top of the psychopy window without needing to minimize it.

Thank you

2 Likes