[Tutor] Is there a heaven for old instances ?
Mon, 10 Dec 2001 11:40:30 -0000
> Now if I create and instance, let's say this way:
> instance1=Button(somewhere, lots of options or none)
> and then for some (stupid?) reason I go:
> instance1=Button(somewhere_else_or_not, new options_maybe)
> what happens to the first instance which is much more
First its not any more complex from Python's point of view
- its just a reference to an object.
BUT because you are presumably referring to Tkinter buttons here you will
when you created themn have passed a parent object as the first parameter.
That Parent keeps a reference to its children, thus although you lost your
reference(instance1) the parent keeps its and the object is not destroyed
until the parent is...
If you still have a reference to the parent you can access the children
from there - but its a bit messy. You can go the other way to because
the widget keeps a reference to its parent too.
Try creating a Frame, sticking some child widgets in it and then doing
a dir() on the Frame and accessing some of the inyteresting properties...