psychopy.org | Reference | Downloads | Github

JS library & Python library

Hi, I am trying to convert python into JS and was wondering where I could find following imported files in Javascript library. I downloaded from github, but I can’t find corresponding files

from __future__ import absolute_import, division
from psychopy import locale_setup
from psychopy import prefs
from psychopy.constants import (NOT_STARTED, STARTED, PLAYING, PAUSED,
                                STOPPED, FINISHED, PRESSED, RELEASED, FOREVER)

Thank you in advance

Builder generates all of that stuff for you automatically when you make an experiment to be run online. Generally we would recommend people just use Builder to get all of that leg-work for you, and restrict yourself to just inserting any small snippets of custom Javascript code that you need to do anything non-standard.

But if you do want to go the route of writing your experiment from scratch in Javascript (it would be interesting to know why), I guess you could just use Builder to generate a dummy experiment and mine the resulting Javascript for template code like this.

How do you use Builder for Javascript?
Doesn’t it only reads python?

Builder doesn’t “read” Python, it generates it, from the description of the experiment you create within the Builder interface. In the same way, if you want to run your experiment online rather than locally, it will simply generate the required HTML and Javascript for you instead. See:

https://www.psychopy.org/online/index.html

Where could I find the libraries for above codes if I still want to code without using the Builder?

I did download it from the github but I don’t see

absolute_import
division
locale_setup
prefs
constants

are they named differently?

That is because some of those things are Python-only concerns (e.g. integer division changed between Python versions 2 and 3). They just aren’t relevant to Javascript.

You really need to be looking at Builder’s Javascript/HTML output as a guide for your own online experiments, rather than the Python output.