Draw/remove additional bounding boxes on image

Hello everyone, new to PsychoPy here.
I’m trying to make a loop in the Builder in which I display one Image at a time with a bounding box on it. The user must be able to move the current box (with the mouse), create additional ones and remove all of them with a button. Then go to the next iteration with the “enter” key.
I’m using mainly the code component, I can move the bounding box, but can’t create or remove them.
Also how do I proceed to the next item? I can only end the whole loop.
Below is the code I’m using.
Thanks a lot for you help!
“”"
win = visual.Window(size=(1920, 1080), color=(1, 1, 1))
h=1080
w=1920

Load an image

background = visual.ImageStim(win, image=ImagePath, size=(2, 2))

Create bounding boxes

bounding_boxes=
initial_box = visual.Rect(win, width=0.1125, height=0.2, lineColor=‘red’, fillColor=None)
bounding_boxes.append(initial_box)
#Have to set for each individual image

Function to update bounding box position based on mouse

def update_bounding_box_position(mouse):
for box in bounding_boxes:
if mouse.isPressedIn(box):
# Get the current mouse position
mouse_pos = mouse.getPos()
# Update the bounding box’s position
box.pos = mouse_pos

mouse = event.Mouse(win=win)

while True:

if 'escape' in event.getKeys():
    break
elif 'b' in event.getKeys():
    new_box = visual.Rect(win, width=0.1125, height=0.2, lineColor='red', fillColor=None)
    bounding_boxes.append(new_box)
elif 'r' in event.getKeys():
    bounding_boxes=[]
# Draw the background
background.draw()

update_bounding_box_position(mouse)

for box in bounding_boxes:
    box.draw()

“”"