Making Button Appear only after Slider Ratings

OS: Win11
PsychoPy version: 2022.1.1
What are you trying to achieve?:

I currently have a routine containing five sliders and a “Next Button”. I want the next button to appear only when the participant has made ratings on all five of the slider scales. This prevents participants from simply clicking through the screens by spamming the Next button without actually making any ratings

What did you try to make it work?:

I have already managed to make this work by typing the following into the Start box of the Next button, and setting the type of entry from time to condition:

rewardSlider.rating and affiliationSlider.rating and dominanceSlider.rating and genuinenessSlider.rating and valenceSlider.rating

What specifically went wrong when you tried that?:

This method only works if I get rid of the Starting Value for each slider. Formerly, I had Starting Value == 5 for all five of the sliders. Unfortunately, this starting value must be registered as a rating, because the Next button appears immediately on the screen if starting values are set. However, I want to do this without getting rid of the starting values. Any ideas how I might I do this?

Hi @SamDay

I guess the simplest way to do it is to set the default colour of your button as lightgrey for instance and to unselect the “Force end of Routine” option.
Then you can add a code component in which you’ll enter in the Each Frame tab :

if slider1.getRating() != 5 and slider2.getRating() != 5 and slider3.getRating() != 5 and slider4.getRating() != 5 and slider5.getRating() != 5 and slider6.getRating() != 5 and slider7.getRating() != 5:
    nextButton.fillColor = 'white'
    nextButton.borderColor = 'blue'
    nextButton.color = 'blue'

if slider1.getRating() != 5 and slider2.getRating() != 5 and slider3.getRating() != 5 and slider4.getRating() != 5 and slider5.getRating() != 5 and slider6.getRating() != 5 and slider7.getRating() != 5 and nextButton.isClicked:
    continueRoutine = False

The first if statement allows you to change the colour of your next button ONLY WHEN every sliders get a rating differing from the default value. This way, your participants will see they are now able to move on.
The second one allows to go to the next routine when the next button is clicked.

The main problem with this solution is that participants cannot rate any slider with 5. If the granularity of your sliders is setted at 0, this should not be a problem as the value given by the participant will almost never be 5.000. However if the granularity is setted at 1, this could be an issue.

If you decide to get rid of the starting values, you can change slider1.getRating()!=5 by slider1.getRating() is not None

Hope this helps a bit.

Hi Ambre, thank you so much! This is extremely helpful and it now works exactly as I’d like. Really appreciate it

1 Like