Is there some way to embed an ico file in my python code similarly to how img2py can embed a png? I want to do this, only not loading it from an outboard file.
icon = wx.Icon('foo.ico', wx.BITMAP_TYPE_ICO)
self.SetIcon(icon)
Thanks,
Michael
Is there some way to embed an ico file in my python code similarly to how img2py can embed a png? I want to do this, only not loading it from an outboard file.
icon = wx.Icon('foo.ico', wx.BITMAP_TYPE_ICO)
self.SetIcon(icon)
Thanks,
Michael
You can do that with img2py as well. It will convert the ico to a png for storing the image data in the file, but you can use the GetIcon() method of the PyEmbeddedImage object to get it as an icon again. Unfortunately this will not maintain multiple versions of the icon image if there is more than one in the .ico file.
On 8/19/10 4:24 PM, Michael Hipp wrote:
Is there some way to embed an ico file in my python code similarly to
how img2py can embed a png? I want to do this, only not loading it from
an outboard file.icon = wx.Icon('foo.ico', wx.BITMAP_TYPE_ICO)
self.SetIcon(icon)
--
Robin Dunn
Software Craftsman
The Python Image Library package has the ability to sequentially read
each image from an ICO file. They can then be reconstituted as a multi-
image ICO file again using PIL, if you want to do that later. The same
can be done with multi-image GIF files as well as reading and setting
the animation timing intervals.
Ray
On Aug 19, 7:49 pm, Robin Dunn <ro...@alldunn.com> wrote:
On 8/19/10 4:24 PM, Michael Hipp wrote:
> Is there some way to embed an ico file in my python code similarly to
> how img2py can embed a png? I want to do this, only not loading it from
> an outboard file.> icon = wx.Icon('foo.ico', wx.BITMAP_TYPE_ICO)
> self.SetIcon(icon)You can do that with img2py as well. It will convert the ico to a png
for storing the image data in the file, but you can use the GetIcon()
method of the PyEmbeddedImage object to get it as an icon again.
Unfortunately this will not maintain multiple versions of the icon image
if there is more than one in the .ico file.--
Robin Dunn
Software Craftsmanhttp://wxPython.org
Thanks. That worked and it's quite easy. Just do ...
img2py -c -i Car.ico icons.py
The -i switch gives it a getCarIcon function, so just do...
from icons import getCarIcon
self.SetIcon(getCarIcon())
Thanks,
Michael
On 8/19/2010 6:49 PM, Robin Dunn wrote:
On 8/19/10 4:24 PM, Michael Hipp wrote:
Is there some way to embed an ico file in my python code similarly to
how img2py can embed a png? I want to do this, only not loading it from
an outboard file.icon = wx.Icon('foo.ico', wx.BITMAP_TYPE_ICO)
self.SetIcon(icon)You can do that with img2py as well. It will convert the ico to a png
for storing the image data in the file, but you can use the GetIcon()
method of the PyEmbeddedImage object to get it as an icon again.
Unfortunately this will not maintain multiple versions of the icon image
if there is more than one in the .ico file.