Tkinter weirdness item count

Peter Otten __peter__ at web.de
Sun May 1 02:51:15 EDT 2005


phil wrote:

> def __del__(s):
> line.count = line.count - 1
> 
> ## delete the line object if the
> ## class instance is deleted
> s.glob.can.delete(s.obj)
> 
> 
> After the rotation I check line.count and it is 3

Did you know that exceptions are ignored in the __del__() method?
One way to verify that your __del__() runs to completion would be to make
the line.count decrement the last statement, and check the total line.count
after the rotation again.
Generally speaking the __del__() method is not the most robust cleanup
mechanism. Maybe you can add a line.delete() method and change your program
flow for it to be called explicitly when the line should no longer be
visible.

Peter




More information about the Python-list mailing list