Hi, I’m in the process of building an experiment.
During the routine [each frame tab], circles [polygon] are added based on a long press on the ‘space’ key.
If the participant leaves the ‘Space’ key, pressing the ‘Space’ a second time will remove the circles from the list as well as their display on the screen.
I have trouble writing the code for the second step [I attached the code I wrote and a video showing its action]
keys = kb.getKeys(['space', 'return'], waitRelease = False, clear=False) for poly in Poly_List: poly.setAutoDraw(True) for thisKey in keys: if thisKey == 'space' and space_func: #code to change the space function polygon = visual.Polygon( win=win, name='polygon', edges=10000, size=(0.1), ori=0.0, pos=(random()-0.5, random()-0.5), lineWidth=1.0, colorSpace='rgb', lineColor='black', fillColor='black', opacity=None, depth=0.0, interpolate=True) Poly_List.append(polygon) core.wait(random()) space_func_minus() #code to change the space function elif thisKey == 'space' and not space_func: for pol in Poly_List: Poly_List.remove(pol) pol.setAutoDraw(False) core.wait(random()) space_func_plus()
The problem is that the circles are not removed in sequence like the sequence that is in adding the circles. And also that the circles are removed in clumps, several at a time.