Size of visual.Window() is influenced by dialogue box

I am using Psychopy v1.85.3 (standalone version) on a win10 Laptop.

My problem: I noticed that the size of visual.Window() is influenced by whether I display a dialogue box before setting up a window. (This troubles me because I fear that the distortion will impact the size of my elements on screen.)

Let me illustrate with an example in code:

from psychopy import core, visual, gui

for i in ['Without preceeding GUI', 'With preceeding GUI']:
    
    if i == 'With preceeding GUI':
        # INFO DIALOGUE
        dict = {'Item:':False}
    
        dlg = gui.DlgFromDict(dict, 'Preceeding GUI')
    
    
    # define a window
    win = visual.Window(
        size=(1536, 864), fullscr=True, screen=0,
        allowGUI=False, allowStencil=False,
        monitor='testMonitor', color=[0,0,0], colorSpace='rgb',
        blendMode='avg', useFBO=True,
        units='cm'
        )
    
    print 'win.size[0] = ', win.size[0] 
    print 'win.size[1] = ', win.size[1]
    
    win.close()
    
core.quit()

This gives me the output:

##### Running: D:\scalingProblem.py #####
win.size[0] =  1536
win.size[1] =  864
1.4637 	ERROR 	avbin.dll failed to load. Try importing psychopy.visual
  as the first library (before anything that uses scipy)
  and make sure that avbin is installed.
win.size[0] =  1920
win.size[1] =  1080
3.8151 	WARNING 	User requested fullscreen with size [1536  864], but screen is actually [1920, 1080]. Using actual size

So, on the first run of the loop my screen size seems to be [1536, 864] and on my second it turns to [1920, 1080]. How is that possible and what does that mean?

What can I do to go sure that a lenght of one with units = ‘cm’ (for any visual object) will really be a centimeter on screen even after displaying a dialogue box?

Thank you for your help!

I can’t replicate your issue.

But I have to ask, why are you requesting a window size that is incompatible with the window being full-screen? Surely if you just ask for a window that is 1920 × 1080 full screen, there wouldn’t be a problem?

i.e. you are feeding incompatible information to the function when creating the window so it is perhaps not surprising that things will go awry (although, as I say, it doesn’t replicate on my system).

Thank you for your answer :slight_smile:
I don’t know what might be different from my laptop to yours since I am new to programming. Did you run it with win10 as well?

If I don’t specify a window size, the default is win.size = (800,600), which is even less correct (see output below). :grimacing: That is why, I thought I would just specify the size of my screen. I tried to find out the size of my screen with win32api:

import win32api

print 'width: ', win32api.GetSystemMetrics(0)
print 'height: ', win32api.GetSystemMetrics(1)

# INFO DIALOGUE
dict = {'Item:':False}
dlg = gui.DlgFromDict(dict, 'Preceeding GUI')


# define a window
win = visual.Window(
    fullscr=True, screen=0,
    allowGUI=False, allowStencil=False,
    monitor='testMonitor', color=[0,0,0], colorSpace='rgb',
    blendMode='avg', useFBO=True,
    units='cm'
    )

print 'width: ', win32api.GetSystemMetrics(0)
print 'height: ', win32api.GetSystemMetrics(1)

core.quit()

But this code also gives me different outputs before and after I use a dialogue box:

##### Running: D:\scalingProblem.py #####
width:  1536
height:  864
width:  1920
height:  1080
2.7749 	ERROR 	avbin.dll failed to load. Try importing psychopy.visual
  as the first library (before anything that uses scipy)
  and make sure that avbin is installed.
3.8936 	WARNING 	User requested fullscreen with size [800 600], but screen is actually [1920, 1080]. Using actual size

I could just let PsychoPy use the actual size and trust the setting win.fullscr = True. But in my experiment, I specify sizes in “cm”, and I want to be sure that these sizes are not skewed when I include a dialogue box at the beginning of my experiment. Can I trust PsychoPy there?

My screen has the folowing measures: 39,62 cm (15,6”), 1.920 x 1.080 pixel, Full HD.

In Windows, are you running your screen at a non-native resolution (i.e. 1536 × 864 rather than 1920 × 1080)?

I had the recommended scaling (1920 x 1080).

There was one other setting for the size of text, apps and other elements, which was set to 125% (recommended; see below). When I change this to 100% my output of the code above is width: 1920 height: 1080 before I call the dialogue box and width: 2400 height: 1350 after I call the dialogue box. So, the starting point is different (1920 x 1080), but the behaviour of the dialogue box, i.e. modifying the resolution, is the same.
Could this be relevant?

Hi, I had the same problem and I think it is really caused by the dialogue box.
I’m using PsychoPy v1.85.3 (not a standalone version) on Anaconda.

In my script, a Window was created after the usage of gui.Dlg.
The reported resolution (i.e., self.win.size) was 1600 x 1280 if a dialogue box was called.
However, when it was removed, the self.win.size became 1280 x 1024.

My original scripts:

# use gui
myDlg = gui.Dlg(title='My experiment')
myDlg.addField('Calibration version?', choices=['adult', 'infant'])
myDlg.addField('Subject number:', var.SUBJECT_NR)
myDlg.addField('Tracking?', choices=['yes', 'no'])
ok_data = myDlg.show()
if myDlg.OK:
    if myDlg.data[0] == 'infant':
        var.CALITYPE = 'infant'
        var.ATT_INTERVAL = 3
    else:
        var.CALITYPE = 'adult'
        var.ATT_INTERVAL = 6
    var.SUBJECT_NR = myDlg.data[1]
    if myDlg.data[2] == 'yes':
        var.TRACKING = True
    else:
        var.TRACKING = False
else:
    print('user cancelled')
    # abort the script if cancelled
    core.quit()
# create a Window to control the monitor

win = visual.Window(size=[1280, 1024],
                    monitor='tobii',
                    units='cm',
                    screen=1,
                    fullscr=True)

self.win.size would incorrectly be 1600 x 1280 in this scenario.

If the dialogue box was removed:

# predefined the parameters
var.CALITYPE = 'adult'
var.ATT_INTERVAL = 6
var.TRACKING = True
var.SUBJECT_NR = 999

# create a Window to control the monitor
win = visual.Window(size=[1280, 1024],
                    monitor='tobii',
                    units='cm',
                    screen=1,
                    fullscr=True)

self.win.size would be 1280 x 1024.

Because I used third-party packages to connect with an eyetracker, I also tested another simple script (as below) without the dialogue box to make sure the problem was not from other packages. The resolution turned out fine.

# Test the calibration points
from psychopy import visual
from psychopy import core

from psychopy_tobii_controller import tobii_controller
import sys

win = visual.Window(size=[1280, 1024],
                    monitor='tobii',
                    units='cm',
                    screen=1,
                    fullscr=True)
DISPSIZE = (34.5, 25.9)
# define calibration points
CALINORMP = [(-0.4, 0.4), (-0.4, -0.4), (0.0, 0.0), (0.4, 0.4), (0.4, -0.4)]
CALIPOINTS = [(x * DISPSIZE[0], y * DISPSIZE[1]) for x, y in CALINORMP]

# preparation of stimuli
marker = visual.Circle(win, radius=1, units='cm', fillColor='green')
# calibration procedure
controller = tobii_controller(win, maxTry=5)
controller.open_datafile('gaze_confirmation.tsv',
                         embed_events=True)
controller.show_status()
ret = controller.run_calibration(
    CALIPOINTS,
    shuffle=True,
    start_key=None
)
if ret == 'abort':
    win.close()
    sys.exit()

# start
controller.subscribe()
core.wait(0.5)
for p in CALIPOINTS:
    marker.setPos(p)
    marker.draw()
    win.flip()
    controller.record_event('start_point_{}'.format([p]))
    core.wait(5)
    win.flip()
    controller.record_event('stop_point_{}'.format([p]))
    core.wait(0.5)  # take a small break

# end
controller.unsubscribe()
controller.close_datafile()
win.close()
core.quit()

I also encounter this problem in win 10.

First, I tried to directly set the width and height of the win size by using size = [1920 1080].

In this case, the dialogue box is not a problem, at least when you open and close the dialogue box before using the win().

But, the part highlighted in the picture matters, at least on my PC. After choosing “100%” instead “125% (recommended)”, the width of the window opened by Psychopy is correct, but not the height, with a few pixels in the lowest part of the screen not covered (like a narrow band below the window opened by Psychopy). This problem is solved by changing “fullscr = False" to “fullscr = True".

But if try to use win32api.GetSystemMetrics(0), it is still 1536, don’t know why.

.

Hi everyone,

I am aware this is a bit of an old topic. But have any of you found a solution for the issue? I am getting the same problem with the gui and the window size. It happens with my surface go (windows 10) but not in my macbook air (Mojave)

Thanks in advance!

best

1 Like

I am in the same boat here. The resolution keeps changing whenever I call the dialog box. I am working also with a 3rd party eye tracker module, and the screen resolution works fine without the dialog, but the moment it pops up, it breaks everything.

I was able to fix this error. Indeed the solution was to change the display resolution that at 125% to 100%

It was like this:
image

And I changed it to this:
image

And it worked!!!