URL of experiment: Pavlovia
Description of the problem: I have (lots of) python code and don’t know which functions PsychoPy can be used in javascript code. For example, this
Q_checkboxes = []
Q_ypos = [.1, 0, -.1, -.2, -.3]
Q_name = ['Checklist','DEQ','State','StateChangeTask','StateChangeDrug']
for (let i = 0; i < Q_name.length; i++) {
Q_checkboxes.push(
visual.Rect(
win=psychoJS.window,
name= Q_name[i],
width=(.05, .05)[0], height=(.05, .05)[1],
ori=0, pos=(0.1, Q_ypos[i]),
lineWidth=1, lineColor=[1,1,1], lineColorSpace='rgb',
fillColor=[1,1,1], fillColorSpace='rgb',
opacity=1, depth=-8.0, interpolate=true)
)
}
is hopefully valid javascript for PsychoPy/Pavlovia, but when I try to run it, I get the error message
ReferenceError: win is not defined
I had hoped that win
would be automatically generated, as it is for an ordinary PyschoPy experiment. When I checked the javascript script, it looked as if psychoJS.window
corresponds to win
in PsychoPy, but I am not sure, because I am still getting the same error.
So my general question are:
- Are functions like
visual.Rect
included in the PsychoJS library? (I couldn’t find rectangles on Status of online options — PsychoPy v2023.2.3, but they seem basic to me.) - Where can I find some more information about how to adapt PsychoPy experiments with lots of python code for pavlovia?
My specific question is, what the reason for the error message above is.
Best, Guido
PS: I think it would be good if the PsychoPy websites were much clearer about the fact that adding code to builder experiments makes running those on pavlovia much more difficult.