psychopy.org | Reference | Downloads | Github

Slider in Online Experiments

URL of experiment: testversion1 [PsychoPy]

Description of the problem: Slider does not show in Online Experiment.

Build with
Psychopy Ver. 2020 1.3
Windows 10

Hey everyone :slight_smile: ,

I have seen some posts about sliders in online experiments, but unfortunateley I haven’t found a fix if they do not appear online at all. So if anyone has a solution for that, I would be super grateful!
I also do not get an error from Pavlovia/Psychopy, only when I check the debug mode from Mozilla, I get the following error:

Because it is complaining about the units, I played with them and also tried ‘pix’ and
‘height’ but for both of them, I got the message ‘is not defined’. When I disable the slider, this error does not occur.

In my experiment I want to use a code component for the slider since the response options depend on the syllable that is presented via audio. And local it runs without problems.

slider = visual.Slider(win=win, name='slider',
    size=(0.5, 0.05), pos=(0, 0), units= None,
    labels=rating, ticks=(1, 2, 3, 4, 5, 6),
    granularity=0, style=('radio',),
    color='green', font='HelveticaBold',
    flip=False)

‘rating’ is the name of column of the excel sheet, in which the response options are defined. And below you can see how it looks like local.

grafik

I know, that my question is quite specific but I would be very thankful for every hint!

Have a look at my crib sheet (pinned post) for a suggestion about dealing with colours

Thanks a lot for your answer- I would have never occured to me to check for the colours. :slight_smile:
Unfortunately I get a new Error in the same routine after adding green in my code component:
“TypeError: can’t convert symbol to string”- but my labels are strings?
Do you have an idea where this is coming from?

I added also “thisColour = new util.Color(Colour);” and get a colour is not defined.
I am a total newbie and happy about every hint!

Please could you show your code components (Python + JS) for defining green and the Slider?

That is the slider and the code component for Psychopy → JS looks like this:

In your slider you should have color=green (no quotes)

In your code_JS you’ve put the Python definition of green on the JS side. It should be green = new util.Color([-1, 0, -1]); (or whatever values you’d like for your preferred green)

Ah yes that makes sense! Thanks for your answer!

Unfortunately I still get the same error:

Sorry for bothering again.

What is line 959 of your JavaScript?

I just checked and it’s slider.setAutoDraw(true);

I think that the issue may be that you’ve defined slider multiple times.

I can see slider = new visual.Slider in rows 230 and 875 and 1237.

Thanks a lot again for your answer. :upside_down_face:
Ah yes, I think had two sliders because it does not draw the slider automatically with
the code I posted above. But I could fix this with the following code:

slider = visual.Slider(win=win, name='slider',
    size=(0.5, 0.05), pos=(0, 0), units= None,
    labels=rating, ticks=(1, 2, 3, 4, 5, 6),
    granularity=0, style=('rating'),
     color= 'green',font='HelveticaBold',
    flip=False)
while not slider.rating:
    slider.draw()
    win.flip()

But I still get the same error online. I also tried changing the style from ‘radio’ to ‘rating’ because in Debug Mode it marked line 1017 for me:

if (this._style.indexOf(Slider.Style.RATING) > -1) ;

draw and flip shouldn’t be used in an experiment created in Builder.

I would recommend creating the slider with a slider component and then manipulating it in code. I have a working slider in my template experiment.