Martin Drautzburg wrote:
In the wx demoy TreeCtrl.py I find the following code, that should have no effect but seems to be needed nevertheless.
class TestTreeCtrlPanel(wx.Panel): def __init__(self, parent, log): [...} self.tree = MyTreeCtrl(self, tID, wx.DefaultPosition, ... isz = (16,16) il = wx.ImageList(isz[0], isz[1]) fldridx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART... [...]
self.tree.SetImageList(il)
--> self.il = il
What is the effect of the last statement? self.il is not used
anywhere. I used similar code in my application and it crashes unless
I assign the image list to the parent panel. The name of the attribute
does not seem to matter. I can write self.foo=il just as well, but
without it it crashes.
You will probably find that without that reference to the image list it will be garbage-collected while the images are still beign displayed, leading to results that are at best unpredictable and at worst fatal to your program.
regards Steve -- Steve Holden http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ Holden Web LLC +1 703 861 4237 +1 800 494 3119 -- http://mail.python.org/mailman/listinfo/python-list