Internally generated "disabled" toolbar images aren't masked correctly.

Hi,

I'm converting an old application that uses wxpython to the latest
version of the library (the last version was from Jan 2007).

One problem I'm having is the toolbars are not showing up correctly. The
"disabled" buttons are being auto-generated by passing in NullBitmap for
bitmap2. I'm attaching a screen shot of the old "working" toolbar (on
top) and the new "mangled" toolbar on bottom. Ignore the extra "properties" icon I added during testing. I have the old version
running in a virtual machine for comparison.

The source is exactly the same. The bitmaps are being made as shown
below and seem correct. The background of the bitmap is standard Windows
grey (192, 192, 192). I've also updated from Python 2.4 to 2.5

The tool is being added with a simple:
     tool_bar.AddLabelTool(id, label, bmp_getter(), longHelp = status_help)

Has anything changed that would cause this to happen?

Thanks in advance,
Sandy

def getBitmap_green_vcr_play():
     stream = cStringIO.StringIO(getImage_green_vcr_play())
     return wx.BitmapFromImage(wx.ImageFromStream(stream))

def getImage_green_vcr_play():
     return \
'\x89\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\
\x00\x00\x00\x10\x00\x00\x00\x10\x08\x02\x00\x00\x00\x90\x91\x68\
\x36\x00\x00\x00\x04\x67\x41\x4d\x41\x00\x00\xb1\x8f\x0b\xfc\x61\
\x05\x00\x00\x00\x5e\x49\x44\x41\x54\x38\x4f\x95\xd2\xc1\x11\xc0\
\x20\x08\x44\x51\xd2\x79\x4a\xa3\xb3\x04\x46\x4f\xc0\x87\xc1\x83\
\x17\xf7\x29\x83\x3c\xaa\x2a\xab\x65\x60\xb5\x24\xa7\xed\xbd\xe6\
\x8a\x78\xe6\xd5\x7d\xbe\x91\x01\xc0\x86\x01\x98\x16\x54\x66\x02\
\xc9\x4c\xe0\x8d\x0d\x68\x41\x4a\xfb\x2f\x87\xf6\xdd\xb6\x5a\x25\
\x55\x9a\x01\xa4\x01\x70\xba\x00\x67\x16\x17\xa3\x31\x0e\x62\x77\
\x59\x89\x7f\xd4\x28\xc4\xb8\x8a\x56\x5b\xff\x00\x00\x00\x00\x49\
\x45\x4e\x44\xae\x42\x60\x82\
'

toolbars.png

Sandy Walsh wrote:

Hi,

I'm converting an old application that uses wxpython to the latest
version of the library (the last version was from Jan 2007).

One problem I'm having is the toolbars are not showing up correctly. The
"disabled" buttons are being auto-generated by passing in NullBitmap for
bitmap2. I'm attaching a screen shot of the old "working" toolbar (on
top) and the new "mangled" toolbar on bottom. Ignore the extra "properties" icon I added during testing. I have the old version
running in a virtual machine for comparison.

The source is exactly the same. The bitmaps are being made as shown
below and seem correct. The background of the bitmap is standard Windows
grey (192, 192, 192). I've also updated from Python 2.4 to 2.5

The tool is being added with a simple:
    tool_bar.AddLabelTool(id, label, bmp_getter(), longHelp = status_help)

Has anything changed that would cause this to happen?

Yep. The MSW toolbar now has better support for images with advanced features like 24-bit color, masks and alpha channels. IIRC, to be able to use the old style masking of BMP files by using the #C0C0C0 color then there are some conversions going on in the code to upgrade the images to a richer format, so it's not too surprising if it messes up when doing a 2nd conversion to be able to make the disabled version.

So my suggestion is to try updating your toolbar images. Either start with some new ones or convert the existing ones to PNGs with either a mask or an alpha channel for the transparent areas, and then redo the embedding of the images into the Python code.

Also, I think there may be some wonky interactions with the XP themes going on as we had this code in Chandler, although I don't remember the details of why:

         if wx.Platform == "__WXMSW__":
             # if we're running on a Themed XP, and the display depth
             # gives us enough bits to play with, then this mode gives
             # us better looking toolbar icons, otherwise stick to the
             # default behavior.
             if wx.GetApp().GetComCtl32Version() >= 600 and wx.DisplayDepth() >= 32:
                 wx.SystemOptions.SetOptionInt("msw.remap", 2)

···

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

Thanks Robin, I'll give the conversion a shot and see how it goes. I tried the wx.SystemOptions.SetOptionInt("msw.remap", 2) previously to no avail.

Cheers,
Sandy

Robin Dunn wrote:

···

Sandy Walsh wrote:

Hi,

I'm converting an old application that uses wxpython to the latest
version of the library (the last version was from Jan 2007).

One problem I'm having is the toolbars are not showing up correctly. The
"disabled" buttons are being auto-generated by passing in NullBitmap for
bitmap2. I'm attaching a screen shot of the old "working" toolbar (on
top) and the new "mangled" toolbar on bottom. Ignore the extra "properties" icon I added during testing. I have the old version
running in a virtual machine for comparison.

The source is exactly the same. The bitmaps are being made as shown
below and seem correct. The background of the bitmap is standard Windows
grey (192, 192, 192). I've also updated from Python 2.4 to 2.5

The tool is being added with a simple:
    tool_bar.AddLabelTool(id, label, bmp_getter(), longHelp = status_help)

Has anything changed that would cause this to happen?

Yep. The MSW toolbar now has better support for images with advanced features like 24-bit color, masks and alpha channels. IIRC, to be able to use the old style masking of BMP files by using the #C0C0C0 color then there are some conversions going on in the code to upgrade the images to a richer format, so it's not too surprising if it messes up when doing a 2nd conversion to be able to make the disabled version.

So my suggestion is to try updating your toolbar images. Either start with some new ones or convert the existing ones to PNGs with either a mask or an alpha channel for the transparent areas, and then redo the embedding of the images into the Python code.

Also, I think there may be some wonky interactions with the XP themes going on as we had this code in Chandler, although I don't remember the details of why:

        if wx.Platform == "__WXMSW__":
            # if we're running on a Themed XP, and the display depth
            # gives us enough bits to play with, then this mode gives
            # us better looking toolbar icons, otherwise stick to the
            # default behavior.
            if wx.GetApp().GetComCtl32Version() >= 600 and wx.DisplayDepth() >= 32:
                wx.SystemOptions.SetOptionInt("msw.remap", 2)

That worked great!

Thanks again,
Sandy

Sandy Walsh wrote:

···

Thanks Robin, I'll give the conversion a shot and see how it goes. I tried the wx.SystemOptions.SetOptionInt("msw.remap", 2) previously to no avail.

Cheers,
Sandy

Robin Dunn wrote:

Sandy Walsh wrote:

Hi,

I'm converting an old application that uses wxpython to the latest
version of the library (the last version was from Jan 2007).

One problem I'm having is the toolbars are not showing up correctly. The
"disabled" buttons are being auto-generated by passing in NullBitmap for
bitmap2. I'm attaching a screen shot of the old "working" toolbar (on
top) and the new "mangled" toolbar on bottom. Ignore the extra "properties" icon I added during testing. I have the old version
running in a virtual machine for comparison.

The source is exactly the same. The bitmaps are being made as shown
below and seem correct. The background of the bitmap is standard Windows
grey (192, 192, 192). I've also updated from Python 2.4 to 2.5

The tool is being added with a simple:
    tool_bar.AddLabelTool(id, label, bmp_getter(), longHelp = status_help)

Has anything changed that would cause this to happen?

Yep. The MSW toolbar now has better support for images with advanced features like 24-bit color, masks and alpha channels. IIRC, to be able to use the old style masking of BMP files by using the #C0C0C0 color then there are some conversions going on in the code to upgrade the images to a richer format, so it's not too surprising if it messes up when doing a 2nd conversion to be able to make the disabled version.

So my suggestion is to try updating your toolbar images. Either start with some new ones or convert the existing ones to PNGs with either a mask or an alpha channel for the transparent areas, and then redo the embedding of the images into the Python code.

Also, I think there may be some wonky interactions with the XP themes going on as we had this code in Chandler, although I don't remember the details of why:

        if wx.Platform == "__WXMSW__":
            # if we're running on a Themed XP, and the display depth
            # gives us enough bits to play with, then this mode gives
            # us better looking toolbar icons, otherwise stick to the
            # default behavior.
            if wx.GetApp().GetComCtl32Version() >= 600 and wx.DisplayDepth() >= 32:
                wx.SystemOptions.SetOptionInt("msw.remap", 2)

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users