Cannot create wx.Bitmap from an wx.Icon in wx 4.0.0a1

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Cannot create wx.Bitmap from an wx.Icon in wx 4.0.0a1

Matt Kimberling
In wxPython 3.0 I could extract the icon from a .exe and create a bitmap by calling wx.BitmapFromIcon:
resourceIcons = win32gui.ExtractIconEx( path, 0 )
hIcon = resourceIcons[1][0] if smallIcon else resourceIcons[0][0]
iconInfo = win32gui.GetIconInfo( hIcon )
bitmapInfo = win32gui.GetObject( iconInfo[4] )
ico = wx.Icon( path, wx.BITMAP_TYPE_ICO, bitmapInfo.bmWidth, bitmapInfo.bmHeight )
ico.SetHandle( hIcon )
bitmap = wx.BitmapFromIcon( ico )
for i in resourceIcons:
for h in i:
win32gui.DestroyIcon( h )
return bitmap

I've been unable to get this to work since upgrading to Phoenix.

The "Classic vs Phoenix" document says the equivalent of BitmapFromIcon is the wx.Bitmap constructor but I've been unable to get that to work.  The wx.Bitmap documentation implies that you could pass the filename to its constructor but I've been unable to get that to work.

Thanks for any help,
 Matt

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Cannot create wx.Bitmap from an wx.Icon in wx 4.0.0a1

Matt Kimberling
I looked at the source code this morning and saw there is a member function for this that isn't (yet) in the docs:

bitmap = wx.Bitmap().CopyFromIcon( ico )


On Tuesday, May 2, 2017 at 8:24:07 PM UTC-7, Matt Kimberling wrote:
In wxPython 3.0 I could extract the icon from a .exe and create a bitmap by calling wx.BitmapFromIcon:
resourceIcons = win32gui.ExtractIconEx( path, 0 )
hIcon = resourceIcons[1][0] if smallIcon else resourceIcons[0][0]
iconInfo = win32gui.GetIconInfo( hIcon )
bitmapInfo = win32gui.GetObject( iconInfo[4] )
ico = wx.Icon( path, wx.BITMAP_TYPE_ICO, bitmapInfo.bmWidth, bitmapInfo.bmHeight )
ico.SetHandle( hIcon )
bitmap = wx.BitmapFromIcon( ico )
for i in resourceIcons:
for h in i:
win32gui.DestroyIcon( h )
return bitmap

I've been unable to get this to work since upgrading to Phoenix.

The "Classic vs Phoenix" document says the equivalent of BitmapFromIcon is the wx.Bitmap constructor but I've been unable to get that to work.  The wx.Bitmap documentation implies that you could pass the filename to its constructor but I've been unable to get that to work.

Thanks for any help,
 Matt

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Cannot create wx.Bitmap from an wx.Icon in wx 4.0.0a1

Robin Dunn
Matt Kimberling wrote:
I looked at the source code this morning and saw there is a member function for this that isn't (yet) in the docs:

bitmap = wx.Bitmap().CopyFromIcon( ico )


It's there: https://wxpython.org/Phoenix/docs/html/wx.Bitmap.html#wx.Bitmap.CopyFromIcon


--
Robin Dunn
Software Craftsman
http://wxPython.org

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.