| Reference | Downloads | Github

How can i change the colour of text stimuli

Hi,How can i change the colour to red when 2 seconds left in duration time when I present a text stimuli for 10 seconds with white colour. Can anyone help please? Thanks very much.

Hi @a544746760, you could add the following to a code component, “Each Frame” tab:

if t >=8 and text.color == "white":
    text.color = "red"

This will set the text component color (text component is called text) to red after 8 seconds, and only if the text is white, therefore not setting the color more than once.

Hi, @dvbridges, thank you very much for helping me! Also, I have another question. T(8 seconds in this case ) is defined as how long the text component has been presented, however, how to dedine the duration time(10 seconds in this case) of text component. I have tried ‘duration’ and ‘duration time’ , however, it does not work.

Oh, do you mean that the text component does not start at time zero of each trial, but later in the trial?

The text component starts at time zero. The main purpose of changing the color of text component is to remind the participants that time is running out when remaining duration time is only 2 seconds.
So I have tried:
if (duration-t) <=2 and text.color == “white”:
text.color = “red”
however, it does not work.Different trials have different duration time,so i want to know how to dedine the duration time of text component.
Thanks again!

I see, so how are you defining the length of each trial?

I do not konw how to define the length of each trial. I tried ‘duration’ and ‘durationTime’, however, it is does not work.