Code without effect (wx demo ImageList)

Paul McGuire ptmcg at
Mon Dec 20 19:16:21 CET 2004

"Martin Drautzburg" <martin.drautzburg at> wrote in message
news:87llbtjujx.fsf at
> In the wx demoy 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)
> --> = il
> What is the effect of the last statement? 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 just as well, but
> without it it crashes.

Two possibilities come to mind:
- used by a base class wx.Panel for which you do not have the source
(although if this were the case, I would think the attribute name would be
- needed to retain a reference handle to the image list, to prevent it from
being garbage collected (kind of far-fetched, but consistent with the "name
it anything you want" behavior)

-- Paul

More information about the Python-list mailing list