| Reference | Downloads | Github

Clicking polygons for questionnaire

Dear all,

This is the first time I am using PsychoPy for an experiment and I am trying to make a questionnaire that participants have to fill in:

I have made questions with multiple choice answers and I have put the multiple choice answers in polygons. I have done so because I want to test the participants on their knowledge of the instructions. I have made two routine screens where one of them holds 6 questions and the next 5 questions. I want participants to fill answers, where they can at the last moment check whether they had them right.

I have two problems:

First problem:
I am able to let participant click on answers and unselect them: the colour changes to red when selected and to white when unselected. However, when clicked the selected polygons will flicker from red to white. I think it is the same problem as in this thread: Stimuli changes colour when clicked but 'flickering' and not responding immediately
I cannot seem to apply it to my experiment somehow, this is my code:

Each frame:

polygons = [rec_1_a, rec_1_b, rec_1_c, rec_2_a, rec_2_b, rec_3_a, rec_3_b, rec_4_a, rec_4_b, rec_4_c, rec_5_a, rec_5_b, rec_5_c, rec_6_a, rec_6_b]

for i in polygons:
    if mouse.isPressedIn(i) and i.fillColor != "red":
        i.fillColor = "red"
    elif mouse.isPressedIn(i) and i.fillColor != "white":
        i.fillColor = "white"

My second problem:

I would like to say that if one of the answers in question 1 (rec_1_a, rec_1_b, rec_1_c) is selected, the others ones must be unselected, so you can only select one answer for a given question.

If somebody has any tips for me this would be much appreciated.



Try i.setFillColor(“red”)

Is this being run locally or online?

Best wishes,


This gives me the following error:
SyntaxError: invalid character in identifier

What I am basically trying to do is get a participant to be able to select and unselect buttons. It does this but it flickers for me for the duration that the mouse press is actually held in, so if you would click the mouse button down for a longer amount of time it would continue flickering.

It is supposed to be run online and I am now running it locally for programming.

Best regards,


Also thank you for your answer, it is much appreciated.

If you are running it online, please look at my crib sheet for how to deal with colours.

Thank you for this, I was not aware of these problems!

If anyone has any comments regarding my initial question, I would greatly appreciate it.

Kindest regards,


This piece of code is asking for the polygon to change colour every frame. The way I deal with this for touchscreens (for which I count contains as a click) is that I also require a change in coordinates.

Alternatively there might be a way of asking for new clicks only

I just found this suggestion of how to register new clicks only from 2016.

1 Like

Exactly the type of answer I was looking for. Your previous answer is the solution I will be using. However, this will definitely help if I need to do something similar in a different way for another experiment. Thank you!