Tkinter Canvas inheritance

Frank Niessink niessink at serc.nl
Mon Mar 19 07:56:53 EST 2001


Markus von Ehr <vonehr at ira.uka.de> wrote:
> 
> When I change the Code and create the image in the main function,
> there's no problem, it works well. How can I do it in the constructor
> and why doesn't it work????

You need to keep a reference to the image else it gets garbage collected.

Change:
>        slider = PhotoImage(file="button.gif")

into:
>        self.slider = slider = PhotoImage(file="button.gif")

Cheers, Frank
-- 
See first, think later, then test. But always see first. Otherwise you will
only see what you were expecting. Most scientists forget that.
	-- Douglas Adams, 'So long, and thanks for all the fish'



More information about the Python-list mailing list