[wxPython] icons with masks

Hi,

I'm using icons in icons in several places in my app. To make them more
professional looking I wanted to mask out their backgrounds. I had a little
trouble with the documentation on how to do this specific task, but I finally
got it to work after several attempts. However, I wonder if my solution is
more complicated than it needs to be. Does anyone know a simpler way to do
this?

For instance for a typical icon I do this:

    self.imglist = wxImageList(16, 16)

    #first icon
    bmp = wxBitmap('bitmaps/arrayp.bmp', wxBITMAP_TYPE_BMP)
    bmp.SetMask( wxMaskColour(bmp, wxColour(0,255,0)) )
    self.arrpicon = self.imglist.Add(bmp)

    #second icon . . .
    bmp = wxBitmap('bitmaps/array.bmp', wxBITMAP_TYPE_BMP)
    bmp.SetMask( wxMaskColour(bmp, wxColour(0,255,0)) )
    self.arricon = self.imglist.Add(bmp)

And it works. It just looks kinda cheesy to me. =)
-Mike

···

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

I'm using icons in icons in several places in my app. To make them more
professional looking I wanted to mask out their backgrounds. I had a

little

trouble with the documentation on how to do this specific task, but I

finally

got it to work after several attempts. However, I wonder if my solution

is

more complicated than it needs to be. Does anyone know a simpler way to

do

this?

For instance for a typical icon I do this:

    self.imglist = wxImageList(16, 16)

    #first icon
    bmp = wxBitmap('bitmaps/arrayp.bmp', wxBITMAP_TYPE_BMP)
    bmp.SetMask( wxMaskColour(bmp, wxColour(0,255,0)) )
    self.arrpicon = self.imglist.Add(bmp)

    #second icon . . .
    bmp = wxBitmap('bitmaps/array.bmp', wxBITMAP_TYPE_BMP)
    bmp.SetMask( wxMaskColour(bmp, wxColour(0,255,0)) )
    self.arricon = self.imglist.Add(bmp)

And it works. It just looks kinda cheesy to me. =)

Yep. Another alternative is to use another bitmap which is only 2-bit to
define the masl, but I can never remember if the white or the black is what
defines mased pixels...

Also, if the file format defines a mask or a background colour (.bmp
doesn't) then wxBitmap and wxImage are supposed to use it automatically.
But I've never tried that either...

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com
http://wxPython.org Java give you jitters?
http://wxPROs.com Relax with wxPython!

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users