Fwd: Tkinter: image handling: bug or feature?

johngrayson at home.com johngrayson at home.com
Fri Jun 1 05:48:50 EDT 2001


--- In python-list at y..., Jose' Sebrosa <sebrosa at a...> wrote:

>> Hi,
>>
>> I just figured out that this code
>>
>> I like to use local names to everything I can (so the names are not
>>available when mainloop is called)
>>
>> Or I'm simplly messing it all...

Yes, you're messing it up...   :-)

If you insist on using local variables, then python is happily
decrementing their reference count as your 'constructor' goes
out of scope and they get garbage collected...

The convention is to make images instance variables. If you are
paranoid about seeing the variables, mangle their names:

    self.__secret_image = ....

John






More information about the Python-list mailing list