Response option on Slider

OS: Win 10
PsychoPy version: v2021.2.3
Standard Standalone? If not then what?: Y
What are you trying to achieve?: I want a real-time comment in response to activity on the slider.

What did you try to make it work?: I made 10 categories on a slider with labels 10 to 100. What I want is that if a participant is selecting for e.g., label 20, then on the left side of the screen, it displays 20, and on the right side, 80, i.e., subtract the selected response from the overall label i.e., 100. And it changes in a realtime if the participant changes the slider in the same trial.

I don’t know how to go about it (either using builder or coder). Please help with this. I need it in my experiment.

If you add a :text: Text or :textbox: Textbox component, you can set its “text” parameter to update each frame, and have it be:

$100-mySlider.rating

(where mySlider is whatever your slider is called)

This means that, each frame, PsychoPy will work out the value and update the contents of the component.

Where do I need to mention “update each frame” as mentioned by you? Since I am new to PsychoPy as well as Python, please help me with this.

Further, on using the code “$100-mySlider.rating” under the text option after changing the slider name, it displays the following error.

line 117, in
text=100-mySlider.rating,
TypeError: unsupported operand type(s) for -: ‘int’ and ‘NoneType’

Next to the input box for text there’s a drop-down menu, you select update each frame there.

Ah, the error is because there’s no rating yet, my mistake! Instead of rating you could use markerPos, and set a start value for the slider.

1 Like

It’s working. Thank You!
Is there an option to avoid displaying decimal value (.0) from the values say 20.0after using “$100-mySlider.rating” code.

There’s one more thing. I need to display the slider value also (without any subtraction, i.e., displaying value 10 when participant select 10 on slider ) separately as text just like it appeared using the code “$100-mySlider.rating”.

The code $100-mySlider.markerPos is saying “set this to be 100 minus the value of my slider’s marker position”, to make another text component without the arithmetic you could just do $mySlider.markerPos.

For the decimal place, there’s a number of ways to control how many decimal places a number is displayed to, but for what you want the easiest way is just int(mySlider.markerPos) - which will convert it to an integer (aka a whole number)

It is working.

I also want the last selected response on the slider to be available on the last slide of the same trial as feedback (what he/she selected on the earlier slide). Further, after 5 such trial loops, I need one final slide where it displays the average of all the last selected values on the slider across 5 trials (like ‘You won 60’ as one text which I get after code ‘$mySlider.markerPos’, and ‘Your opponent won 40’ as second text that I obtained after code ‘$100-mySlider.markerPos’). I meant the average of all the values that I got after applying these codes across 5 trial loops. Please help with it too.