Reputation: 155
How do I make it so that the circles in this list can be modified or removed later on? Isn't the list different from the actual objects?
def drawAllBubbles(window,numOfBubbles):
bublist=list()
for x in range(numOfBubbles):
p1= random.randrange(1000)
p2= random.randrange(1000)
center= graphics.Point(p1,p2)
bubx = center.getX()
buby = center.getY()
r = random.randint(1, 255)#randomize rgb values
g = random.randint(1, 255)
b = random.randint(1, 255)
circle = graphics.Circle(center, 5)
circle.setFill(color_rgb(r, g, b))
circle.setOutline("black")
circle.draw(window)
bublist.append(circle)
return bublist
window.getMouse()
This part of the script essentially draws
And then returns a list of circles.
Upvotes: 0
Views: 80
Reputation: 428
The objects are contained in bublist
If you iterate over the list, you can change, remove, or redraw the circles. For example:
for bubble in bublist:
bubble.setOutline("green")
bubble.draw(window)
Upvotes: 1