PyGaze with Pyglet
Hi all,
I have a stimulus code that uses the Pyglet library to create and animate some OpenGL figures. I would like to use an EyeTracker to synchronize with the stimulus and then get the eye gaze data.
I understand that PyGaze is already prepared for PsychoPy and PyGame. Since I have the stimulus in Pyglet, I believe that I would have to modify the libscreen, libtime and libinput libraries.
Is modifying these files the only solution? Has anybody used Pyglet with PyGaze?
Thank you,
jl
Comments
Hi jl,
There are two options:
1) Rewrite Display and Screen (and possibly Keyboard and Mouse). Basically, this means implementing all the existing functionality (provided through PyGame and PsychoPy) by wrapping Pyglet.
2) Use the EyeTracker class with an active PyGaze Display under the PsychoPy display type, then hijack the Pyglet window. The recipe would be fairly straightforward:
constants.py
experiment.py
Good luck!
Hi Edwin,
Thank you very much for your answer.
I have tried to put the second option in practice, but I have not succeeded. I understand that
pygletwin = pygaze.expdisplay.winHandlewill create a pyglet window, but I have not found any documentation on how to use it.
Following the code in your answer, I have tried to make something simple as to display a square on the screen, but the screen remains empty and there is no error message.
This is the code I am using:
Thanks for your help.
Could it be because you call
pygletwin.clear()before callingpygletwin.flip()?You mention you already have the Pyglet code for your stimulus, so I assumed you were familiar with it's
Windowclass. I am not, but I did find some documentation here.Good luck!
Hi Edwin,
Thank you for your answer.
I made the following mistake (but I have not solved my problem): nothing was being drawn because the
pyglet.clear()call was after drawing the square. Now the while loop looks like this:When
pygletwinis initialzed as a normal pyglet window, i.e.pygletwin = pyglet.window.Window(), the square is drawn. However, when I usepygletwin = disp.expdisplay.winHandle, nothing is drawn.I am more or less familiar with the Pyglet Window class, but, sorry, I was not clear that I was refering to the
winHandlemethod, that I believe it is a method of the PsychoPy window, but I have not found any documentation at all.Thank you very much for your help, I really appreciate it.
jl