invalid bitmap for wxToolBar icong

Hello,
I’m trying to set the images for a toolbook layout. I’ve made my own images.py file by feeding my PNG files into img2py.py. I also tried coverting the files to .bmp and then feeding them into encode_bitmaps.py. Both times I got the following error message:

File “mytoolbook.py”, line 82, in main
frame = MainFrame(None, -1, ‘Title’, (600,400))
File “mytoolbook.py”, line 37, in init
tb.AddPage(pgOne, “PageOne”)
File “/usr/lib/python2.7/wx/_core.py”, line 13619, in AddPage
return core.BookCtrlBase_AddPage(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion “bitmap.IsOk()” failed at /home/mttp/cwc/wxPython-src-3.0.0.0/src/gtk/toolbar.cpp(261) in SetImage(): invalid bitmap for wxToolBar icon

Is there something simple I’m missing here?

mytoolbook.py (2.25 KB)

By the way I’m using wxPython 3.0 on Debian Wheezy.

Hello,
I’m trying to set the images for a toolbook layout. I’ve made my own images.py file by feeding my PNG files into img2py.py. I also tried coverting the files to .bmp and then feeding them into encode_bitmaps.py. Both times I got the following error message:

File “mytoolbook.py”, line 82, in main
frame = MainFrame(None, -1, ‘Title’, (600,400))
File “mytoolbook.py”, line 37, in init
tb.AddPage(pgOne, “PageOne”)
File “/usr/lib/python2.7/wx/_core.py”, line 13619, in AddPage
return core.BookCtrlBase_AddPage(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion “bitmap.IsOk()” failed at /home/mttp/cwc/wxPython-src-3.0.0.0/src/gtk/toolbar.cpp(261) in SetImage(): invalid bitmap for wxToolBar icon

Is there something simple I’m missing here?

Yeah.

iconList = [‘image_1’,
‘image_2’,
‘image_3’]

needs to be calling the images

iconList = [images.image_1,
images.image_2,
images.image_3]

then later on when you need them…

···

On Monday, March 3, 2014 8:13:53 AM UTC-6, Matt Pagan wrote:

for i in iconList:
bmp = i.GetBitmap()
il.Add(bmp)

Matt Pagan wrote:

Hello,
I'm trying to set the images for a toolbook layout. I've made my own
images.py file by feeding my PNG files into img2py.py. I also tried
coverting the files to .bmp and then feeding them into
encode_bitmaps.py. Both times I got the following error message:

File "mytoolbook.py", line 82, in main
frame = MainFrame(None, -1, 'Title', (600,400))
File "mytoolbook.py", line 37, in __init__
tb.AddPage(pgOne, "PageOne")
File "/usr/lib/python2.7/wx/_core.py", line 13619, in AddPage
return _core_.BookCtrlBase_AddPage(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion "bitmap.IsOk()" failed at
/home/mttp/cwc/wxPython-src-3.0.0.0/src/gtk/toolbar.cpp(261) in
SetImage(): invalid bitmap for wxToolBar icon

Is there something simple I'm missing here?

You can verify if the bitmaps are valid after you fetch them with GetBitmap by using IsOk(). If it's false there then make sure that there wasn't a problem with the img2py step. You'll also want to make sure that they are all the right size.

···

--
Robin Dunn
Software Craftsman