psychopy.org | Reference | Downloads | Github

Export Python code to html

OS (e.g. Win10): OS Sierra & Win10
PsychoPy version (e.g. 1.84.x): Psychopy3 Beta10 & Beta8
Standard Standalone? (y/n) If not then what?: Yes
What are you trying to achieve?: I’m trying export my python code written in the Coder view to html in order to upload it to Pavlovia (The code runs smoothly on Psychopy).

What did you try to make it work?: My understanding is the “export to html” function only works in the Builder view. And I didn’t find any instructions about converting written python code into all of the necessary files that are needed for Pavlovia. If I cannot achieve it through Pavlovia’s standalone, is there anything else I can use??? And if I have to convert it manually, what are the necessary files?

Thanks so much!

Correct. I t would take a lot of artificial intelligence to convert your custom-written Python code to Javascript/html.

Make a simple experiment in Builder and see what it generates. Work from there. But you are going to need to learn Javascript and and the other associated web technologies. Are you sure it won’t be easier to just create your experiment in Builder and let it do all the hard work for you? At most, you might just need to convert a few custom Python code snippets in code components to Javascript. This will be much easier than writing the entire experiment that way.

Thanks so much Michael! That makes everything much clearer.

Hi Michael,

Just an additional related questions: Once the scripts are uploaded online, do they still have the ability to read from the local files? I’m thinking about creating the experiment design files locally (so we don’t need to re-do this in JS) in Python and have those data read in the JS files, but I’m not sure whether the uploaded script will have the ability to do that once online.

Thanks for all the help you’ve given!

If by “local files”, you mean files in the same directory as your experiment file (e.g. conditions files, images, etc), then yes, all those files (including ones in sub-folders) get uploaded as well, so they become local to the online copy of the experiment. PsychoPy uses git to handle the synchronisation, and this operates on at level of the entire project folder, not just a particular experiment script. Conversely, you can choose to exclude certain files from this process by editing the invisible .gitignore file.

Cool thanks so much!

Best,

Danlei