'set every frame' in Online Experiment

Hi all,

I wanted to make a slider and an image corresponding the slider rating value like what I wrote before: Sliders with images. But translating it to online experiment, I had a problem with it, since, as crib sheet (PsychoPy Python to Javascript crib sheet - Online experiments - PsychoPy) indicated, ‘set every frame’ is broken in online experiment. As before, I would like to move my slider using keyboard and get image having corresponding values so that I wrote this:

image

arrowKeys = event.getKeys(keyList=['left', 'right'])
if 'left' in arrowKeys:
    cur = slider_practice.getRating()
    slider_practice.recordRating(cur-1)
    sld_img.image = stim_id[int(slider_practice.getRating())]

if 'right' in arrowKeys:
    cur = slider_practice.getRating()
    slider_practice.recordRating(cur+1)
    sld_img.image = stim_id[int(slider_practice.getRating())]

and also for my slider to begin with a value randomly chosen from a set of values,
image

Plus, my image component(sld_img) is:

image

The first problem is that the slider had no initial marker at the beginning of routine:

(when the experiment runs without image component)

The marker came out and I could make it move using keyboard only after I clicked the slider. I have tried to add:

slider_practice.markerPos = current_anchor
slider_practice.markerPos

and run the experiment with this and failed. How can I show the marker at start?

The second problem is that images did not change with slider values. It changed only after I clicked the slider and press left or right arrow. When I pressed the keys a few more times, the slider changed, but the image did not change.

When I edited my slider code like this:

arrowKeys = event.getKeys(keyList=['left', 'right'])
if 'left' in arrowKeys:
    cur = slider_practice.getRating()
    slider_practice.recordRating(cur-1)

if 'right' in arrowKeys:
    cur = slider_practice.getRating()
    slider_practice.recordRating(cur+1)

sld_img.image = stim_id[int(slider_practice.getRating())]

,the image disappeared like the screen above, without any image component. Is there any way to handle this problem?

Thank you

I’d say that since 2020.2 Set Every Frame is discouraged rather than broken.

However, I think that your issue is with setting sliders using the keyboard, rather than Each Frame code.

However, does this help

It seems to recommend ._recordRating not .recordRating

Thank you for your answer. I’ve already seen the code in the link you gave and this was why I named my slider slider_practice . However, I got an error message with ._recordRating:

TypeError: slider_practice._recordRating is not a function