psychopy.org | Reference | Downloads | Github

Problem running GUI demo

Hi,

I am having issues running (and using) the GUI demo. Here is what it says:

(x86)\PsychoPy3_PY2\lib\site-packages\psychopy\demos\coder\input\GUI.py ##
Traceback (most recent call last):
File “C:\Program Files (x86)\PsychoPy3_PY2\lib\site-packages\psychopy\demos\coder\input\GUI.py”, line 21, in
fixed=[‘ExpVersion’]) # this attribute can’t be changed by the user
File “C:\Program Files (x86)\PsychoPy3_PY2\lib\site-packages\psychopy\gui\qtgui.py”, line 455, in init
Dlg.init(self, title, screen=screen)
File “C:\Program Files (x86)\PsychoPy3_PY2\lib\site-packages\psychopy\gui\qtgui.py”, line 129, in init
nScreens = len(qtapp.screens())
AttributeError: ‘QApplication’ object has no attribute ‘screens’

Any ideas how to solve this issue?

Best,
André

My guess is that this is ultimately because you are using the Python 2 version of PsychoPy3. Do you need that specifically, or can you get the Python 3 version (the one without PY2 in the name)? You can download it here: https://github.com/psychopy/psychopy/releases

More specifically, I would guess that the Python 2 version is using either an outdated version of qtgui library, or a too advanced version of qtgui that isn’t friendly with Python 2. If you need Python 2, either avoid using gui or report it here: https://github.com/psychopy/psychopy/issues

upping this one.
When I run a script containing gui.DlgFromDict from the Coder editor, it fails with this error. However if I copy the commands in the Python 2 terminal, I can see the dialog.
We are phasing out Python2 but some experiments cannot be changed right now, so we need some Python2 support for a while.

Hey,

I’ve commented on your raised issue on Github and sent in a PR but if you’re still after a fix - in the qtgui.py file on line 129 - general path to folder on Windows is:

C:\Program Files (x86)\PsychoPy3_PY2\Lib\site-packages\psychopy\gui

If you replace:

        nScreens = len(qtapp.screens())

With the following instead:

        if haveQt == 'PyQt5':
            nScreens = len(qtapp.screens())
        else: 
            nScreens = QtWidgets.QDesktopWidget().screenCount()

It should work as a temporary workaround - @jonathan.kominsky was right that it was trying to call a newer version of qtgui (.screens came in Qt5, this version has Qt4 available). I’ve added here in case approach is of use to anyone else.

1 Like