arghh, colour wxBitmapButton problem ...

I've been trying desperately for the last few hours to get
a colour wxBitmapButton working. It seems so simple:

             imgfile = 'arrow_down.jpg'
             bmp = wx.Bitmap(imgfile, wx.BITMAP_TYPE_JPEG)
             # or alternatively
             # bmp = wx.Image(imgfile, wx.BITMAP_TYPE_JPEG).ConvertToBitmap()
             b = wx.BitmapButton(self, -1, bmp, (xpos, ypos), (bmp.GetWidth(), bmp.GetHeight()) )

but my buttons thus created don't appear properly. I've put a
screen capture of a test app on:

     http://anusf.anu.edu.au/~dee900/Projects/wxPython/

along with two of the source images. I've tried converting
the source images in Photoshop to 8-bit PNG, index-colour,
etc., all to no avail.

Looking at the wxPython wxBitmapButton demo, the
authors use hardcoded XPM images rather than loading from
a file via one of the wx image loaders. Surely one can load from
a file though, no?

Any help is much appreciated.

Cheers,
Darran.

···

--
Darran Edmundson (darran.edmundson@anu.edu.au)
ANU Supercomputer Facility Vizlab
Australian National University, Canberra, ACT 2600
tel: +61 2 6125-0517 fax: +61 2 6125-5088

Darran Edmundson wrote:

I've been trying desperately for the last few hours to get
a colour wxBitmapButton working. It seems so simple:

but my buttons thus created don't appear properly. I've put a
screen capture of a test app on:

    http://anusf.anu.edu.au/~dee900/Projects/wxPython/

along with two of the source images. I've tried converting
the source images in Photoshop to 8-bit PNG, index-colour,
etc., all to no avail.

Looking at the wxPython wxBitmapButton demo, the
authors use hardcoded XPM images rather than loading from

Actually they are PNG images that have been encoded into a Python source file using the img2py tool included with wxPython.

a file via one of the wx image loaders. Surely one can load from
a file though, no?

Yes. The problem you are running into is a known problem with BitmapButtons on wxMac. I don't know the details but it is something to do with which native format that is being used to give the image to the native control. If you put the same image in wx.StaticBitmap then you'll see that it is being loaded okay.

···

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