Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the icon of the produced .exe, py2exe

Ive been googling this however none of the results worked for me.

Here is my setup file

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

The icon of the actual .exe file should be "myicon.ico". However this does not happen and is the default icon. "myicon.ico" is 32 x 32.

I am using windows 7.

like image 630
thelost Avatar asked Mar 10 '12 20:03

thelost


1 Answers

I've had this problem before (though I'm using windows XP). A recent snippet of code that worked for me:

from distutils.core import setup

setup(
    options = {'py2exe': {'bundle_files': 1}},
    zipfile = None,
    windows = [{
            "script":"myprogram.pyw",
            "icon_resources": [(1, "myicon.ico")],
            "dest_base":"myprogram"
            }],
)

This creates one .exe file that you can use to distribute (even includes windows libs -- so use caution there)

My .ico file was 64 x 64 and I used a tool to create it from a JPG (something like http://www.favicon.cc/) Sometimes with Photoshop and GIMP saving a file as .ico with default settings is not quite enough, so be aware you might have to do something else there.

like image 154
hharnisc Avatar answered Sep 22 '22 20:09

hharnisc