Setting slider labels from Begin Routine

I want to set the labels for a slider from a line in Begin Routine. As far as I can tell, this is how to do it but it doesn’t work.

slider.labels = (“option1”,“option2”)

I have tried a lot of different combinations and nothing works.

I have even tried commands show here

and here

Is this even possible? Is there a glitch? Please help ASAP.

Did you try accessing directly to the class?
For example:

slider = visual.Slider(win, labels= ("option_1", "option_2"))


Thanks for the prompt response. Based on your suggestion, I put the following line in the Begin Routine tab of a code component (in Python window). My slider name is item1.

item1 = visual.Slider(win, labels = (“option1”,“option2”))

Let me know if I did something wrong. All I get is a blank page but when I click on the page (roughly where the radio buttons should be) I get a big red dot but there are no labels.

Is item1 the name of your slider in the builder?
If not, can you please share the experiment you are working on? Maybe only with the relevant part.



It works! The reason the text wasn’t showing up is that I am using a white background. When using your win method, it sets to defaults for ticks and color regardless of what is set in builder.

Can you explain why your method works and why my original method did not? If I use your method, it seems like I am bypassing builder so I’ll have to use a bunch of other lines to set colors, ticks, etc.

Thanks for helping with this.


Hello Ken,
In your original method, did you set the color of the text to be different than the color of your background? I wasn’t sure if this is something you found out accidentally using my method or if it’s something else.

I also tried replicating your method, and I am unsure why it doesn’t work. I tried accessing the labels through an external variable, in a spreadsheet, but nothing seemed to work.
It seems like updating the label after initializing it is problematic.

No. I had the color set to black for labels via builder. However, I just noticed that there was an error in the JS version. Using single quotes at least got rid of that error but it still didn’t work. I even tried putting this line in Each Frame tab. That didn’t work either.

item1.labels = (‘option1’,‘option2’)

I guess in future I will be forced to use your method. Hopefully someone can figure this out.

I couldn’t find a better solution than manually creating the slider through code. I hope someone else find a better solution because the current one is not trivial.