Adding delays in for loops that are executed in Every Frame?

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

OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 2020.2.3
Standard Standalone? (y/n) If not then what?: Y
What are you trying to achieve?:

I have programmed a memory game, where participants see 60 white circles. On each trial, some circles turn black (and then back to white) indicating that they are target circles. The participant will then wait for five seconds, and then click on as many of the target circles as they can remember. They always have the same number of guesses as there are targets (i.e., if there are 5 targets, they will have 5 guesses). If they click on a circle that is a target, it will turn green, and if they click on a circle that is not a target, it will turn red.

On some trials, they are able to opt for a helper (which is a programmed helper, not a real helper). The helper is either reliable (correct 83.33% of the time) or unreliable (correct 16.67% of the time). A picture of the available helper appears in the top left of the screen. The participant can click on as many target circles as they remember, and can then click on the helper if they want help. If they click on the helper, the helper will finish the rest of their guesses for that trial. If the helper chooses a circle that is a target, it will turn green, and if the helper chooses a circle that is not a target, it will turn red.

The task itself will run from start to finish with no major issues. However, I want to make a change, and am hitting the same problem each time I try.

Currently, when the participant clicks on a helper, all of the circles chosen by the helper will appear at the same time. I would like to change this so that the circles chosen by the helper appear progressively, as if someone was actually helping. However, I am having trouble adding a delay/pause in the relevant for loop, and I believe this is because it is executing in the Each Frame section.

So my question is whether getting the circles to progressively appear is possible, and how I can approach solving this problem.

Here is my current code, for reference:

if aidedtrials.thisN == 0:
    for stimulus in allstimuli:
        if aidedresponses.isPressedIn(stimulus):
            helperextra = 0 #Default helper end of trial time
            if stimulus in helper: #RELEVANT CODE FOR HELPER (these are the circles I want to progressively appear)
                helperremainingclicks = clicksremaininginfo
                bothlist = [1,2] #target list = 1, nontarget list = 2
                for circle in range(helperremainingclicks): #this is the number of guesses remaining
                    chosenlist = np.random.choice(bothlist, p=[.1667,.8333])
                    ClickCount = ClickCount + 1
                    clicksremaininginfo = clicksremaininginfo - 1
                    print("chosen list", chosenlist)
                    if chosenlist == 1: #target list 
                        chosencircle = np.random.choice(targetsremaining1)
                        #chosencircle.fillColor = (0,128,0)
                        totalscoreinfo = totalscoreinfo + 1
                    else: #nontarget list (bad)
                        chosencircle = np.random.choice(nontargetsremaining1)
                        #chosencircle.fillColor = (255,0,0)
                    print("Helper Chose:", helperchose)
                    helperextra = 2 
                for selected in circlestocolour:
                    if selected in targetlist1:
                        selected.fillColor = (0,128,0)
                        #ClickCount = ClickCount + 1
                        selected.fillColor = (255,0,0)
                        #ClickCount = ClickCount + 1
            elif list(stimulus.fillColor) == [1.,1.,1.]: #This is for when the participant is clicking the circles themselves (rather than getting chosen by a helper)
                ClickCount = ClickCount + 1
                clicksremaininginfo = clicksremaininginfo - 1
                if stimulus in targetlist1: #Target (green) 
                    stimulus.fillColor = (0,128,0)
                    totalscoreinfo = totalscoreinfo + 1
                else: #Nontarget (red)
                    stimulus.fillColor = (255,0,0)
                    print("not a target")
    if ClickCount == len(targetlist1) and not trial_ending:
        trial_end_time = t + 1.0 + helperextra
        trial_ending = True 
    if trial_ending and t >= trial_end_time:
        continueRoutine = False 

What did you try to make it work?: and What specifically went wrong when you tried that?:

I have left my commented out code in the above so you can see some attempts at solving the issue. I originally tried to colour the helper-chosen circles immediately after they were being chosen. I then tried adding a wait (I tried core.wait and also imported time to try time.sleep) in that same loop, which I was hoping would mean that one circle would be chosen/coloured before it chose/coloured the next circle. Instead, it would delay the appearance of the coloured circles, but they would still all appear together.

I then tried creating a separate for loop for colouring the circles (see ‘for selected in circlestocolour’), and adding the pauses in there, which had the same result.

I also tried using while loops, breaks, continues, and also trying to execute some of the code in ‘end Routine’, all of which either gave similar results to above, or did nothing at all.

I have also considered adding a new routine, but doing so requires the circles to be named differently to how they are named in this routine. The code that determines which circles are selected by the ‘helper’ uses a lot of information from the current routine (i.e., lists that are progressively built based on participant’s responses), which would then become redundant in a routine with differently named circles.

Any advice would be very much appreciated!