[open] pygame within Psychopy backend
Is it possible to call a function from pygame when the experiment runs with the Psychopy backend?
I use Psychopy for its ability to stick to the refresh rate, but the keyboard input does not recognize accented letters. So I wrote a script that should handle keyboard events using pygame. This script gives the expected results when the Legacy backend is on, but the for loop is not active when the Psychopy backend is selected.
The script is:
import pygame
pygame.init()
cpt = 1
while cpt<100:
for event in pygame.event.game()
print event
self.sleep(20)
cpt = cpt + 1
pygame.quit()
Comments
It's perfectly possible to mix and match different back-ends, even without using code. Do this by going to your experiment script (click on the top item in the overview, then click the
Script Editorbutton). The start of your script will look like the following:If you want to use the PyGame back-end for the keyboard, change it to:
If all you want is a blocking flip, you can also use the
xpyrimentback-end. This is built on pygame, so you could use pygame functions without any hacks. I'm not sure what will happen if you switch only the keyboard back-end tolegacy, as @edwin suggests. But I suspect it won't work (?), because pygame doesn't own the psychopy window.Check out SigmundAI.eu for our OpenSesame AI assistant!
That's a very good question, I hadn't actually tried. Simply assumed this would work