Overriding slider with code

I’m trying to use the slider component at the beginning of my experiment to allow participants to select their gender from a series of radiobuttons.
I was struggling with how to edit the text size and found this post:

Unfortunately I don’t seem to be able to override the slider with the code.

Any advice greatly appreciated.

Hi @newbie2, if you take the code from the link above and paste it into a code component, in the Begin Routine tab, but set the labelHeight to your choice, the labels should change size in your task. Please note to make sure that the name of the slider you created in Builder matches that in the code. E.,g.,

mySliderName = visual.Slider(...

Anyone can teach me psychopy please because I get different error messages even after following instructions line by line from the book.

Hi @seema, it would be a good idea to start a new post with the details of what you are doing, and the problems you are having, and you could also paste the errors you are receiving.

Apologies if I’m missing something glaringly obvious but I’ve done exactly that and my text height still doesn’t change.
I’ve attached my program if that helps (it’s literally just the gender question currently).

gender.psyexp (7.7 KB)

I see, yes your slider is called gender, so you would use:

gender = visual.Slider(...etc

My mistake! Thanks so much.

Sorry to ask another question, but at the moment this is a slider but I want it to be radio buttons as it’s gender.
I’ve tried knownStyles=[‘radio’] but this comes up as an “unexpected keyboard argument”.
I also tried replacing visual.slider with visual.radio and just ‘Radio’ but those don’t seem to be recognised terms either.

gender = visual.Slider (win=win, name=‘radio’, knownStyles=[‘radio’]

Nearly there, it is just the style parameter that needs changing:

gender = visual.Slider (win=win, name=‘radio’, style=[‘radio’], granularity=1,

You should also set the granularity to 1 (see above) if you are making categorical ratings.

So close!
Thanks once again!