Tkinter Canvas Items - not ref counted?

Randall Hopper aa8vb at vislab.epa.gov
Mon May 3 13:47:49 EDT 1999


     Why does the Canvas Rectangle and its canvas item not get destroyed
using the following fragment:

 from Tkinter import *
 from Canvas import *
 root = Tk()
 canvas = Canvas( root )
 canvas.pack()
 rect = Rectangle( canvas, 1, 1, 100, 100 )
 rect = None                                  # <--- Destroy it here
 root.update_idletasks()

You can see the rectangle even after the "rect = None" executes.

Randall




More information about the Python-list mailing list