psychopy.org | Reference | Downloads | Github

Changing features form component without changing source code?

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 3.2.3
Standard Standalone? (y/n) If not then what?: y
What are you trying to achieve?: Changing details in the form component (e.g., radio button color) without changing the source code

Hello!
I try to change some details in my experiment, especially default colors. I take the example of the form, slider type ‘radio’. The default color of the radio button is red when clicked.
I went to the visual > slider code and changed the color there.

But I have to put my experiment on approx. 20 computers and I don’t feel like changing the coe everywhere, especially because I will not be the only one to use psychopy there.

Can I make these changes in a code component? I tried, but it doesn’t seem to work (I can’t link my code to the slider code for example).

Any ideas? Thank you!!

Hi @Oceane, in the “Begin Experiment” tab, you can add the following line of code, to change the slider marker color

slider.marker.color = "green"

Hello @dvbridges,
it works for sliders indeed.
Yet in this case I use the slider within the form component, and this line doesn’t work (NameError: name ‘slider’ is not defined). It makes sense because with the form there is no slider as such.

Sorry, I misread! You could instead try the following (where your Form component is called yourForm):

# Begin Experiment
for item in yourForm.formElements['response']:
    item.marker.color = "green"

There are some new Form features that should be in the next release, such as ability to set question text and response colors.

Hey @dvbridges,
ok so this works and thank you, however I am totally unable to apply the logic to other features (e.g., text color, lines thickness) :frowning: