wxImageList outside wxListCtrl

I'm trying to create a wxImageList for use in a number of classes.
When I create it in a wxListCtrl class and adding the images as
per the demo works fine. When I move the wxImageList creation
outside the class, the Add image fails and warns about no
handler for image type. Sadly wxInitAllImageHandlers causes a
Seg Fault.

Any suggestions?

Nigel

···

--
Nigel W. Moriarty
Building 4R0230
Physical Biosciences Division
Lawrence Berkeley National Laboratory
Berkeley, CA 94720-8235
Phone : 510-486-5709
Fax : 510-486-5909
Email : NWMoriarty@LBL.gov
Web : CCI.LBL.gov

Nigel Moriarty wrote:

I'm trying to create a wxImageList for use in a number of classes.
When I create it in a wxListCtrl class and adding the images as
per the demo works fine. When I move the wxImageList creation
outside the class, the Add image fails and warns about no handler for image type. Sadly wxInitAllImageHandlers causes a
Seg Fault.

Sounds like you have a bigger problem than just wxImageList. Can you reproduce it in a small sample app?

···

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

I have attached some sample code.

···

#----------------------------------------------------------------------
# This file was generated by C:\PROJECTS\wx\wxPython\demo\encode_bitmaps.py
#
from wxPython.wx import wxImageFromStream, wxBitmapFromImage
from wxPython.wx import wxEmptyIcon
import cStringIO

def getMondrianData():
    return \
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\
\x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x00qID\
ATx\x9c\xed\xd6;\n\x800\x10E\xd1{\xc5\x8d\xb9r\x97\x16\x0b\xad$\x8a\x82:\x16\
o\xda\x84pB2\x1f\x81Fa\x8c\x9c\x08\x04Z{\xcf\xa72\xbcv\xfa\xc5\x08 \x80r\x80\
\xfc\xa2\x0e\x1c\xe4\xba\xfaX\x1d\xd0\xde]S\x07\x02\xd8>\xe1wa-`\x9fQ\xe9\
\x86\x01\x04\x10\x00\\(Dk\x1b-\x04\xdc\x1d\x07\x14\x98;\x0bS\x7f\x7f\xf9\x13\
\x04\x10@\xf9X\xbe\x00\xc9 \x14K\xab a\xf0\x00\x00\x00\x00IEND\xaeB`\x82'

def getMondrianBitmap():
    return wxBitmapFromImage(getMondrianImage())

def getMondrianImage():
    stream = cStringIO.StringIO(getMondrianData())
    return wxImageFromStream(stream)

def getMondrianIcon():
    icon = wxEmptyIcon()
    icon.CopyFromBitmap(getMondrianBitmap())
    return icon

from wxPython.wx import *

image_list = wxImageList(16,16)
rc = image_list.Add(getMondrianBitmap())

On Tue, 07 Oct 2003 13:02:41 -0700 Robin Dunn <robin@alldunn.com> wrote:

Nigel Moriarty wrote:
> I'm trying to create a wxImageList for use in a number of classes.
> When I create it in a wxListCtrl class and adding the images as
> per the demo works fine. When I move the wxImageList creation
> outside the class, the Add image fails and warns about no
> handler for image type. Sadly wxInitAllImageHandlers causes a
> Seg Fault.

Sounds like you have a bigger problem than just wxImageList. Can you
reproduce it in a small sample app?

--
Nigel W. Moriarty
Building 4R0230
Physical Biosciences Division
Lawrence Berkeley National Laboratory
Berkeley, CA 94720-8235
Phone : 510-486-5709
Fax : 510-486-5909
Email : NWMoriarty@LBL.gov
Web : CCI.LBL.gov

Nigel Moriarty wrote:

I have attached some sample code.

[..]

from wxPython.wx import *

image_list = wxImageList(16,16)
rc = image_list.Add(getMondrianBitmap())

Try creating a wxApp object before the image list. This works fine for me:

from wxPython.wx import *
app = wxPySimpleApp()
image_list = wxImageList(16,16)
rc = image_list.Add(getMondrianBitmap())

···

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