When I draw a rectangle in global scope:
c = Canvas(width=IMAGE_WIDTH, height=IMAGE_HEIGHT, bg='black')
c.create_rectangle([100, 100, 110, 110], fill='white')
c.pack()
root = Tk()
and follow this by drawing a few rectangles in a loop
class gDrawer :
def __init__(self) :
self.rect_array = []
self.x = 0
self.y = 0
def incr_counter(self,c,event=None):
one_pixel_loc = [self.x, self.y, self.x+5, self.y+5]
self.rect_array.append(c.create_rectangle(one_pixel_loc, fill='white'))
self.x += 1
gd = gDrawer()
for xx in range(100) :
print xx
gd.incr_counter(c)
root.mainloop()
The only drawn rectangle remains on the canvas, while the rectangular rectangle moves, rather than creating a trace of the rectangles. I would like to draw the trajectory of the rectangles, and not move, and what happens here?
source
share