wxPython question

M.E.Farmer mefjr75 at hotmail.com
Fri Dec 17 17:37:01 CET 2004

André wrote:
> I needed to scale the image down to 16 by 16 on my Windows computer
> make it work.

Hello André,

# I actually ran this code ;)
import wx
app = wx.PySimpleApp()
class myframe(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,None,-1,"Icon Frame",
frame = myframe()
# this image is 32*32 on my computer
image = wx.Image('c:/Python22/pycon.ico', wx.BITMAP_TYPE_ANY)
image = image.ConvertToBitmap()

icon = wx.EmptyIcon()



This works fine for me I am on windows 2000, and pycon.py is 32*32*24
Wonder why you had to resize?

On another note, be sure to check out the tools dir in either the
wxpython dir or wx dir it has a script called img2py.py.

img2py.py  --  Convert an image to PNG format and embed it in a Python
module with appropriate code so it can be loaded into
a program at runtime.  The benefit is that since it is
Python source code it can be delivered as a .pyc or
'compiled' into the program using freeze, py2exe, etc.

Be sure to use the -i flag so it will convert it to a wxIcon
Once you convert your icon to source using img2py.py you can do this:
import Icon
ICON = Icon.getIcon()


More information about the Python-list mailing list