If this template helps then use it. If not then just delete and start from scratch.
OS (e.g. Win10): OS X
PsychoPy version (e.g. 1.84.x): 2020.2.4
Standard Standalone? (y/n) If not then what?:
**What are you trying to achieve?:**Have the fill color of the textbox change from a list in an excel file. I’m trying to make several textboxes that all change background color after a certain time elapses, from a variable in an excel file. Just as once can make for polygons.
**What did you try to make it work?:**tried the $-method that works for color settings for polygons. So far I have a so-so workaround by making the textbox complete seethrough and placing a polygon behind it. Problem is that the polygon has to have low opacity (.2 for example) which actually changes the color of the polygon (from bright yellow at 1-opacity to dirty yellow at .2-opacity)
What specifically went wrong when you tried that?: Well, it didn’t work! And it seems like it is not a supported feature, but I stil wanted to create a topic about it and ask
Include pasted full error message if possible. “That didn’t work” is not enough information.
OK so I think I was able to replicate this error, to clarify, is the error you are receiving:
AttributeError: ‘Rect’ object has no attribute ‘fillRGB’
Hi Becca, thanks for the quick reply!
Well, I’m not really getting any error message, the script just quits before the first routine even starts. As long as I have one color, it runs fine, as soon as I try to make it conditional (and change after each repeat), it just doesn’t execute the script beyond entering the participant number.
Attaching a screenshot of how I try to set it up.
Ah, looks like this is one use case we missed! It seems to be calling
setFillColor on textbox, but that method doesn’t exist. You can get around this by setting it to be constant, then adding a Code component with this in the Begin Routine tab:
textbox_2.fillColor = cHex
I’ll get a fix for this in for the next release
Thank you for the reply. I did try your suggested solution and it did not work for me. Script exits after entering the participant number. Even created a new script only consisting of one textbox and inserted the code you suggested and that one didn’t run either (I did rename textbox_2 from your code to match the name of the object I had created).
Could you send over the .psyexp files you tried?
Sure, sending both the .psyexp and the .xlsx that contains conditions for the routine
questions_textboxes.xlsx (8.9 KB) textbox.psyexp (9.5 KB)
Whoops, that was my mistake!
updateColors is something I recently put in the developer branch, it isn’t in 2020.2 yet… Just remove that line and it should be alright
Thanks for the answer. Still didn’t manage to make it work on my machine. However I figured out the JS code so I’m just piloting it online and it is working. Since I’ll be running the study online due to covid-related restrictions, it is a workaround I can live with. Thanks for taking your time.