psychopy.org | Reference | Downloads | Github

Feedback with colored text

If this template helps then use it. If not then just delete and start from scratch.

OS : Win10
PsychoPy version : 3.0.5
**Standard Standalone?: yes
What are you trying to achieve?:
I believe my problem should be relatively easy to solve. However, for whatever reason I cannot get my issue resolved myself. Basically, I want feedback that is a specific color based on whether the participant responded correctly or incorrectly.

What did you try to make it work?:
There are various resources online showing how to add feedback to a routine. After using the one provided on Psychopy’s website,

https://www.psychopy.org/recipes/builderFeedback.html

I managed to get my experiment to present “correct” or “incorrect” when the participant answers accordingly. To do this, I added a new routine after the main trial routine. This new routine contains a code component and a text component.
The text component contains $msg in the text box, and is set to every repeat. The code component has two elements:
Begin Experiment: msg=’ '.
Begin Routine:
if key_resp.corr:
msg=“correct”
else:
msg=“incorrect”

This works fine, but I want the correct text to be displayed in green, and the incorrect text to be displayed in red. How would I achieve this?

Hi @Steve_Pierzchajlo, set your color of your text component to a variable (e.g., msgColor), set that to update on every repeat, and add the following to the Begin routine tab:

if key_resp.corr:
    msg = "correct"
    msgColor = 'green'
else:
    msg = "incorrect"
    msgColor = 'red'

This worked! Thank you very much.