Adjust Code from Psychopy to Pavlovia

hi all,
I have a Psychopy task that runs offline for quite a while. I now want to create an online version but I encountered a problem. I believe the issue lies in the code I added in the Psychopy builder that failed to be converted to java (I tried the automatic options).
In the experiment, participants are being asked to type sequences of numbers. After every keypress, a feedback element in the form of ‘polygon’ appears on the screen. To achieve that I used a code that was added in the Psychopy builder.
In the beginning of the experiment – import python toolboxes

In the beginning and in each frame of the routing- a counter element that controls the opacity of the polygons

And used as a condition inside the polygons

Works like a charm in Psychopy but crushes in Pavlovia.

Can you help?



*Attached is the original task files before converting to an online versionnumbers_NOport200220.psyexp (97.0 KB)

Do you really need all these python libraries? They are not automatically converted to JavaScript. You might want to rewrite your experiment without using these libraries, try the auto-translate option. You probably still have to manually edit the JavsScript-code (set auto translate to both) and see Wake Carter crib sheet for python to JavaScript translation.

best wishes Jens

to further add to jens point, many of those libraries are actually automatically imported (and the psychoJS counterparts are imported behind the scenes for your online experiment) - so you don’t actually need to manually import these :slight_smile:

Thanks for the suggestions.

I tried to remove this section or import only parts of the toolboxes but then it doesn’t recognize the variable ‘event’ that is defined based on the toolboxes.

I tried to perform an automatic conversion as you suggested but it didn’t work. I guess the solution is indeed to adjust it manually. I will try to use the website you suggested… I hope it will help because I have zero experience in java scripting.

Thanks again,



In the experiment you uploaded you use event.clearEvents() Why do you use it? See here

Best wishes Jens

If you need the event module online you can add a code component, set type to ‘JS’ and in the ‘begin experiment’ tab type:


If you need any other conversions like that take a look at the crib sheet :slight_smile: