Differences between revisions 6 and 18 (spanning 12 versions)
Revision 6 as of 2004-01-30 11:53:52
Size: 636
Editor: 202
Comment:
Revision 18 as of 2005-02-04 11:37:50
Size: 2486
Editor: 81-86-95-56
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Icons are added as {{{icon_rsources}}} Icons are added as {{{icon_resources}}} 
Line 4: Line 4:
setup(  setup(
Line 15: Line 15:
The resouce number does not seem to matter. Windows just takes the first existing icon. The resource number does not seem to matter. Windows just takes the first existing icon.
Line 22: Line 22:
Line 23: Line 24:


'''How to add small and large icons'''

You must create ico file with two icons in one.
Your icon file must contain small ico (size: 16*16 pixels) and large ico (size: 32*32 pixels). For WindowsXP you probably may create a big ico (48*48) - but it's only for XP.
Almost all popular icon editors can create complex icon with small and large part in one. For instance, [http://www.x2studios.com/index.php?page=products&id=11 LiquidIcon] is a freeware icon editor that lets you combine multiple ico files of different sizes and bit-depths into a single ico file. Also available is [http://www.winterdrache.de/freeware/png2ico/ png2ico], a GPL'ed command line-only {{{.ico}}} creator capable of generating icons with multiple sizes, bit depths, and transparency settings.

Now I've managed to give an icon to my program, but when the program starts, a standard Windows icon shows up in the window's title bar and in the task bar button (instead of my custom icon). Is there a way I can fix that myself, or is that a current limitation of py2exe?

As far as putting icons on your window itself (above is just for the file in explorer I think) it depends on the gui library you are using.
For wxWindows 2.4 it would be something like this where self is a wx.Frame derived class instance
Example: {{{
#!python
    _icon = wx.EmptyIcon()
    _icon.CopyFromBitmap(wx.Bitmap("MyIcon.ico", wx.BITMAP_TYPE_ANY))
    self.SetIcon(_icon)
}}}

The following also works, at least in wxPython 2.5.2.8 and other recent ones. {{{
#!python
    _icon = wx.Icon('MyIcon.ico', wx.BITMAP_TYPE_ICO)
    self.SetIcon(_icon)
}}}


This should allow the system to pick an appropriate icon. ( only tested with 2.5.3 ) {{{
#!python
    ib=wx.IconBundle()
    ib.AddIconFromFile("MyIcon.ico",wx.BITMAP_TYPE_ANY)
    self.SetIcons(ib)
}}}
 

Icons are added as icon_resources

setup(
    windows = [
        {
            "script": "with_gui.py",
            "icon_resources": [(1, "myicon.ico")]
        }
    ],
)

The same practice works as well for console and windows scripts. The resource number does not seem to matter. Windows just takes the first existing icon.

/!\ if somebody knows how to add small and large icons, speak up...

Hm, doesn't the .ico file contain them?

does the resource number refers to the icon's index in the .ico file (if containing > 1 icons) ?

-- [mailto:dswsh@plasa.com dody wijaya]

How to add small and large icons

You must create ico file with two icons in one. Your icon file must contain small ico (size: 16*16 pixels) and large ico (size: 32*32 pixels). For WindowsXP you probably may create a big ico (48*48) - but it's only for XP. Almost all popular icon editors can create complex icon with small and large part in one. For instance, [http://www.x2studios.com/index.php?page=products&id=11 LiquidIcon] is a freeware icon editor that lets you combine multiple ico files of different sizes and bit-depths into a single ico file. Also available is [http://www.winterdrache.de/freeware/png2ico/ png2ico], a GPL'ed command line-only .ico creator capable of generating icons with multiple sizes, bit depths, and transparency settings.

Now I've managed to give an icon to my program, but when the program starts, a standard Windows icon shows up in the window's title bar and in the task bar button (instead of my custom icon). Is there a way I can fix that myself, or is that a current limitation of py2exe?

As far as putting icons on your window itself (above is just for the file in explorer I think) it depends on the gui library you are using. For wxWindows 2.4 it would be something like this where self is a wx.Frame derived class instance Example:

   1     _icon = wx.EmptyIcon()
   2     _icon.CopyFromBitmap(wx.Bitmap("MyIcon.ico", wx.BITMAP_TYPE_ANY))
   3     self.SetIcon(_icon)

The following also works, at least in wxPython 2.5.2.8 and other recent ones.

   1     _icon = wx.Icon('MyIcon.ico', wx.BITMAP_TYPE_ICO)
   2     self.SetIcon(_icon)

This should allow the system to pick an appropriate icon. ( only tested with 2.5.3 )

   1     ib=wx.IconBundle()
   2     ib.AddIconFromFile("MyIcon.ico",wx.BITMAP_TYPE_ANY)
   3     self.SetIcons(ib)

CustomIcons (last edited 2011-08-05 21:58:17 by SunjayVarma)