| Reference | Downloads | Github

Questions about a slider

Hi, I have some questions about a slider.

in my procedure I need to have 5 sliders in one routine.

I need a slider, which have values from 0 to 100,
where I can stop the marker on a value,
I can accept all my choices by click on button

For now I built:

when I chose a value it disapears fast. How I can change my slider to wait for other slider and save when i click on button?

My code:

I am a begginer at PsychoPy and I tried to adding something to this code but it doesn’t work

Hi @sylwia3234, if you create your slider using Builder i.e., add a slider to a routine using the dialog button, rather than coding it, then you can uncheck the button “Force end of routine”. Now you can use the slider without ending the trial. To get the trial to end only when both sliders are rated, and a button is pressed, adapt the following code for use in the “Each Frame” tab of a code component:

if slider1.getRating() and slider2.getRating() and mouse.isPressedIn(button):
    continueRoutine = False
1 Like

When I want to use 'space" instead of mouse how can I change this code?

You could use the following, assuming your keyboard is called “resp”:

if slider1.getRating() and slider2.getRating() and resp.keys == 'space':
    continueRoutine = False
1 Like

Ok, in my final experiment I have 5 sliders so I multiply sliders in this code and change the names of sliders on mine. However when I run experiment and it also go next without answears.

Could this be a problem with my slider start position set? (slider.markerPos = 50) and psychopy reads it as answear?

Do you mean that the user can press space without having to make any ratings? If so, check your keyboard settings and ensure that “Force end of routine” is deselected.

The subject should answer every slider, if he does not do so, by pressing the space key the procedure should not go further. Space will only work if it responds to all sliders.

Thanks, if you see the post above, please check the keyboard state for ending the routine. Also, you will also need an amendment to the code, which wipes the keyboard presses that occur before the sliders have been rated:

if slider1.getRating() and slider2.getRating() and resp.keys == 'space':
    continueRoutine = False
    resp.keys = []
    resp.rt = []
1 Like

Oh I am a bit confused, don’t know what I am doing wrong, now it also go next without responds to all sliders:

  1. I deselected the boxes of “Force end of routine” in every slider.
  2. The part of this experiment look like that I have: 2 routines: routine with photo and routine with this 5 sliders and in one loop. I change this code like this:

if slider1.getRating() and slider2.getRating() and slider3.getRating() and slider4.getRating() and slider5.getRating() and space_next.keys == ‘space’:
continueRoutine = False
space_next.keys = []
space_next.rt = []

I add this code in Each Frame. I don’t know what you mean about “that occur before sliders have been rated”, I treid to add this at the top of componets but it was problem with definition of sliders names.

Ok, not sure what is happening, but here is an example using 3 sliders and a keyboard. Take a look and see if you can see what is different in your code:

sliderTest.psyexp (11.4 KB)

I did everything from the beginning comparing to your file and now everything works great. Thanks for the help!