3
當我畫在全局範圍內的矩形:爲什麼Tkinter在繪圖時擦掉前面的矩形?
c = Canvas(width=IMAGE_WIDTH, height=IMAGE_HEIGHT, bg='black')
c.create_rectangle([100, 100, 110, 110], fill='white')
c.pack()
root = Tk()
,並通過在循環繪製的矩形移動,而在一個循環
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()
在畫布上單繪製的矩形住宿畫多個矩形遵循此比創建一個矩形的蹤跡。我想繪製一些矩形,而不是一個移動的矩形,所以這裏發生了什麼?
我想要你的寶寶!事實上,事實證明,因爲我只是在每次重繪下一個像素時將「像素」移動小於輪廓大小,它將覆蓋黑色輪廓的前一個像素。 – funkyeah 2011-06-13 16:13:18