psychopy.org | Reference | Downloads | Github

Change background color using _fillColor.rgb as per the documentation

I create a simple visualTextStim and try to change the background color.

t = visual.TextStim(
            win, 
            text='placeholder, 
            color=black, 
            colorSpace='rgb',
) 

t._fillColor.rgb = [1,0,0]

According to the documentation fillRGB is deprecated and instead I should use obj._fillColor.rgb

Changing this appears to have no effect. The same can be said for obj._borderColor.rgb.

However, obj.foreColor.rgb does work.

This is because a TextStim has no fill color - it’s just text so only has a foreground. For a text stimulus with a fill and border you’d use TextBox2.

It’s essentially inherited fill color / border color attributes from the base visual class, I’ll look into overriding them for TextStim so that the documentation is clearer that these don’t apply to this class :slight_smile:

Okay! That makes a lot of sense in hindsigh!.

The documentation caused me quite some confusion as I was trying to get this running.