esdalmaijer / PyGaze

an open-source, cross-platform toolbox for minimal-effort programming of eye tracking experiments
www.pygaze.org
GNU General Public License v3.0
671 stars 211 forks source link

Cannot get mouse position from PsychoPy #48

Closed cherepaha closed 7 years ago

cherepaha commented 8 years ago

Not sure if it's a general issue or a local config problem, but for me the following code throws an exception

from pygaze import libscreen, libinput

disp = libscreen.Display(disptype='psychopy')
mouse = libinput.Mouse(disptype='psychopy')

test_screen = libscreen.Screen(disptype='psychopy')    
disp.fill(screen=test_screen)
disp.show()    
current_mpos = mouse.get_pos()
disp.close()
Traceback (most recent call last):

  File "<ipython-input-1-90c7ba8a9569>", line 1, in <module>
    runfile('C:/Python27/pygaze_issue_1.py', wdir='C:/Python27')

  File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 685, in runfile
    execfile(filename, namespace)

  File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 71, in execfile
    exec(compile(scripttext, filename, 'exec'), glob, loc)

  File "C:/Python27/pygaze_issue_1.py", line 9, in <module>
    current_mpos = mouse.get_pos()

  File "C:\Python27\lib\site-packages\pygaze\libinput.py", line 406, in get_pos
    return psychopos2pos(self.mouse.getPos())

  File "C:\Python27\lib\site-packages\psychopy\event.py", line 390, in getPos
    lastPosPix[1] = self.win.size[1]/2-lastPosPix[1]

AttributeError: 'weakref' object has no attribute 'size'

Again, I'm quite sure something's wrong with my PsychoPy settings (attached just in case), so I'll appreciate any suggestions

psychopy_userPrefs.cfg.txt

esdalmaijer commented 8 years ago

Thanks for reporting this. Could you confirm that you are using the latest version of PyGaze? This issue should have been resolved by referring to pygaze.expdisplay in the Mouse class (line 59) rather than a weakref. So if you're using the newest version, it shouldn't happen.

BTW: The issue is due to a change in PsychoPy, not due to your PsychoPy settings. PyGaze should be compatible with the newer versions of PsychoPy since we changed the aforementioned line.

cherepaha commented 8 years ago

Great, thanks for this! I was just a bit confused about which version of PyGaze to use. As I relied heavily on online documentation, I decided to use the 'stable' version (that is, 0.4) for my project, because it seemed like some changes in the newest version aren't reflected in the docs. However, now it seems I have to switch to the current version anyway.

esdalmaijer commented 8 years ago

Good point! I should update the stable version to 0.5. Documentation still applies, by the way :)

cherepaha commented 7 years ago

For the sake of completeness, created #78 and #81 regarding documentation and version update