adding icons to a tree control

Hello,

I'm trying to add icons to a tree ctrl class I've created with this code:

        dirIcon =im1 = -1
        self.ilist = wxImageList(16, 16)
        im1 = self.ilist.Add(treeIcons.getFolder1Bitmap())
        self.SetImageList(self.ilist)

but I get the following error when I use a test icon from the demo folder images.py (which I renamed to treeIcons)

What am I doing wrong? I copied the code straight from the demo.

Guy

  File "C:\Documents and Settings\redarch\Desktop\TCE\rfatree.py", line 12, in __init__
    im1 = self.ilist.Add(treeIcons.getFolder1Bitmap())
  File "C:\Documents and Settings\redarch\Desktop\TCE\treeIcons.py", line 3614, in getFolder1Bitmap
    return wxBitmapFromImage(getFolder1Image())
  File "E:\PYTHON22\lib\site-packages\wxPython\image.py", line 387, in wxBitmapFromImage
    val = apply(imagec.wxBitmapFromImage,_args,_kwargs)
wxPyAssertionError: C++ assertion "wxAssertFailure" failed in e:\projects\wx\src\msw\bitmap.cpp(507): invalid image

Guy Robinson wrote:

Hello,

I'm trying to add icons to a tree ctrl class I've created with this code:

        dirIcon =im1 = -1
        self.ilist = wxImageList(16, 16)
        im1 = self.ilist.Add(treeIcons.getFolder1Bitmap())
        self.SetImageList(self.ilist)

but I get the following error when I use a test icon from the demo folder images.py (which I renamed to treeIcons)

What am I doing wrong? I copied the code straight from the demo.

Before you mess with putting images in a .py file you should try loading from plain image files to make sure there is not something else going on. The images that are in demo/images.py are also in demo/bmp_source if you need to copy some. For example, try this:

  self.ilist.Add(wxBitmap("folder1.bmp", wxBITMAP_TYPE_BMP))

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!