wx.ImageList.GetIcon() not working on MacOS with wx.Bitmap

Dear All,

I have code that works like a charm under Win32 but not at all on the
Mac.

I’m storing wx.Bitmap instances in an wx.ImageList.

Then I call the_image_list.GetIcon(the_index) and under Win32
this is fine.

Under MacOS (this is Python 2.5.x and wxPython 2.8.9.1) I get an
assertion error:`

File “./sarnie_client.py”, line 75, in
restoreIcon

self.overrideIcon(IMAGE_LIST.GetIcon(SARNIE_CLIENT_ICON))

File
“//usr/local/lib/wxPython-unicode-2.8.9.1/lib/python2.5/site-packages/wx-2.8-mac-unicode/wx/_gdi.py”,
line 6083, in GetIcon

return _gdi_.ImageList_GetIcon(*args, **kwargs)

wx._core.PyAssertionError: C++ assertion “wxAssertFailure” failed at
/BUILD/wxPython-src-2.8.9.1/src/mac/carbon/imaglist.cpp(153) in
GetIcon(): cannot convert from bitmap to icon`

Any suggestions?

Whilst I have your attention: I’m using this icon with wx.TaskBarIcon.
Does this all work on the Mac? Moreover, how does the right-click
pop-up menu work on the Mac for wx.T``askBarIcon?

JOOI: Are there any Mac / Python / wxPython developers out there
willing to help in my project? :blush:

TIA

-R

Ranec wrote:

Dear
All,

I have code that works like a charm under Win32 but not at all on the
Mac.

I’m storing wx.Bitmap instances in an wx.ImageList.

Then I call the_image_list.GetIcon(the_index) and under Win32
this is fine.

Under MacOS (this is Python 2.5.x and wxPython 2.8.9.1) I get an
assertion error:`

File "./sarnie_client.py", line 75, in

restoreIcon

self.overrideIcon(IMAGE_LIST.GetIcon(SARNIE_CLIENT_ICON))

File
“//usr/local/lib/wxPython-unicode-2.8.9.1/lib/python2.5/site-packages/wx-2.8-mac-unicode/wx/_gdi.py”,
line 6083, in GetIcon

return _gdi_.ImageList_GetIcon(*args, **kwargs)

wx._core.PyAssertionError: C++ assertion “wxAssertFailure” failed at
/BUILD/wxPython-src-2.8.9.1/src/mac/carbon/imaglist.cpp(153) in
GetIcon(): cannot convert from bitmap to icon`

Any suggestions?

Whilst I have your attention: I’m using this icon with wx.TaskBarIcon.
Does this all work on the Mac? Moreover, how does the right-click
pop-up menu work on the Mac for wx.T``askBarIcon?

JOOI: Are there any Mac / Python / wxPython developers out there
willing to help in my project? :blush:

TIA

-R

So I’ve looked at wxPython-src-2.8.9.1/src/mac/carbon/imaglist.cpp
and it seems you can only use wx.ImageList.GetIcon() on the Mac if you
out wx.Icon’s into the list.

So instead of loading wx.Bitmap’s I load wx.Icon’s (from my PNG files)
and put them in my image list then I lose transparency in Win32. :frowning:

Am I going to have to write platform-specific code or is there a way
for the same code to be used on both MacOS and Win32 that can make
icon’s for task bars and menus and that both platforms have
transparency?

What are good on-line resources for using wxPython code on both MacOS
and Win32.

Help!

TIA

-R

Hello,

Ranec wrote:

Dear All,

I have code that works like a charm under Win32 but not at all on the Mac.

I’m storing wx.Bitmap instances in an wx.ImageList.
Then I call the_image_list.GetIcon(the_index) and under Win32 this is fine.

Under MacOS (this is Python 2.5.x and wxPython 2.8.9.1) I get an assertion error: File "./sarnie_client.py", line 75, in restoreIcon self.overrideIcon(IMAGE_LIST.GetIcon(SARNIE_CLIENT_ICON)) File "//usr/local/lib/wxPython-unicode-2.8.9.1/lib/python2.5/site-packages/wx-2.8-mac-unicode/wx/_gdi.py", line 6083, in GetIcon return _gdi_.ImageList_GetIcon(*args, **kwargs) wx._core.PyAssertionError: C++ assertion "wxAssertFailure" failed at /BUILD/wxPython-src-2.8.9.1/src/mac/carbon/imaglist.cpp(153) in GetIcon(): cannot convert from bitmap to icon

Any suggestions?

Use ImageList.GetBitmap instead. If you need to convert to icon for some reason you can call Bitmap.ConvertToImage.

Whilst I have your attention: I’m using this icon with wx.TaskBarIcon. Does this all work on the Mac? Moreover, how does the right-click pop-up menu work on the Mac for wx.T``askBarIcon?

Yes, look in the wiki there are a number of examples:

http://wiki.wxpython.org/Custom%20Mac%20OsX%20Dock%20Bar%20Icon?highlight=%28taskbaricon%29

Cody

···

On Jan 13, 2009, at 11:50 AM, Ranec wrote:

Cody Precord wrote:

Hello,

Ranec wrote:

Dear
All,

I have code that works like a charm under Win32 but not at all on the
Mac.

I’m storing wx.Bitmap instances in an wx.ImageList.

Then I call the_image_list.GetIcon(the_index) and under Win32
this is fine.

Under MacOS (this is Python 2.5.x and wxPython 2.8.9.1) I get an
assertion error:`

    File "./sarnie_client.py", line 75, in

restoreIcon

self.overrideIcon(IMAGE_LIST.GetIcon(SARNIE_CLIENT_ICON))

File
“//usr/local/lib/wxPython-unicode-2.8.9.1/lib/python2.5/site-packages/wx-2.8-mac-unicode/wx/_gdi.py”,
line 6083, in GetIcon

return _gdi_.ImageList_GetIcon(*args, **kwargs)

wx._core.PyAssertionError: C++ assertion “wxAssertFailure” failed at
/BUILD/wxPython-src-2.8.9.1/src/mac/carbon/imaglist.cpp(153) in
GetIcon(): cannot convert from bitmap to icon`

Any suggestions?

Use ImageList.GetBitmap instead. If you need to convert to icon for
some reason you can call Bitmap.ConvertToImage.

Whilst I have your attention: I’m using this icon with wx.TaskBarIcon.
Does this all work on the Mac? Moreover, how does the right-click
pop-up menu work on the Mac for wx.T``askBarIcon?

Yes, look in the wiki there are a number of examples:

http://wiki.wxpython.org/Custom%20Mac%20OsX%20Dock%20Bar%20Icon?highlight=%28taskbaricon%29

Cody

Wow, cheers Cody, I’ll test that today. On Win32 it’s doing the trick!
:slight_smile:

-R

···

On Jan 13, 2009, at 11:50 AM, Ranec wrote: