Different round() behaviour online and desktop

OS Win10
PsychoPy version v2022.1.2
Standard Standalone? yes

I have built an experiment in which participants are asked to adjust a slider. The value of the slider is displayed above it. To achieve this I have used a code component to define “thisPos”

thisPos = slider.getMarkerPos()

And then a text component to display the number:

$'Current rating: ’ + str(round(thisPos, 2))

This is done so that the number displayed is rounded to 2dp, instead of being a very long string. Weirdly this works completely fine online, but when trying to run it in the builder on my desktop, I get this error:

ratingText.setText('Current rating: ’ + str(round(thisPos, 2)), log=False)
TypeError: type NoneType doesn’t define round method

I would much rather be able to test the experiment on the desktop, so any help in understanding why the behaviours differ would be much appreciated.

Hi, this is happening because the slider doesn’t have a start value so if you set a start value, it should fix the error. Although, if you do not want a start value, you can set the text component start time to condition and in the field, use slider.rating. This means that this component only starts when there is a rating.

So in my code component I have thisPos = 0 in the Begin Routine tab. Is this what you mean?

Hi, not really. I made a minimal demo to demonstrate what I was referring to in my previous comment.

show_slider_rating.psyexp (12.3 KB)

1 Like

Thanks! This makes sense now