Bringing PsychoPy Coder Experiment Online

Hello,

I have written an experiment in the Coder view for Psychopy. I’m reading about bringing it online, but it appears I can only do so from the Builder view, or if I recode my experiment in Javascript.

I am hoping that someone can confirm whether my thinking is accurate. I’m hoping that I’m actually just missing a step and I’ve overlooked a way to translate my Psychopy code to run it online.

Thanks in advance for any help!

Amy

Hi Amy,

Python is not a language that runs within a web browser. So most online experiments (not just PsychoPy/Pavlovia) are written in JavaScript, which is supported by all web browsers.

So you are correct: you would either need to translate your existing experiment code into JavaScript, or redo it graphically in Builder, which will handle the JavaScript generation for you.

Hi Michael,

Thank you for your reply! I understand that my Python script needs to be translated in order to be run on a browser, and by your response it is clear I will need to do this manually. I was hoping I was missing an easy translation process within Coder view, but manually will have to do :slight_smile:

Thanks again,
Amy

Code components in the Builder view have an auto-translate feature that generates a JavaScript equivalent to a given bit of custom Python code. This works surprisingly well for many of the relatively small code snippets that are typically used there. You could try pasting in sections of your code there to see what it comes up with, but it would probably be a bad idea to rely on automated translation for an entire script.

There might be other translation services out there online, but the advantage of using PsychoPy’s code components is that the translator knows a little bit about PsychoPy-specific API code.

I am having the same problem. I built an experiment that is a watered down pong game that relies on the pygame library. Is this possible to create this in builder with the auto-translate feature?

In what way does it rely on pygame?

Collision detection between ball and paddle

That doesn’t really answer the question (how does it rely upon pygame)? e.g. can it just be achieved through geometry? Or via PsychoPy’s own overlap detection built into its visual stimuli: