How to set a Custom Windows Icon with Py2Exe

By default, we see the below taskbar icon when running a sample application (built with py2exe):

a default application icon on windows, not custom

As shown on the py2exe site, we can add the following line:

"icon_resources": [(1, "myicon.ico")]

to our script. The code is now:

from distutils.core import setup
import py2exe
from cefpython3 import cefpython
import wx
import time
import re
import uuid
import platform
import inspect
import struct
import urllib
        'script': '',
        "icon_resources": [(1, "myicon.ico")]

The icon file I used was created using IcoFX (not free, but very handy) as detailed here. The result is:

the custom application icon with the windows app open

To set the icon in the upper-left portion of the application window, you can add the following code (documented here) to the code file (, in our example):

_icon = wx.Icon('app.ico', wx.BITMAP_TYPE_ICO)

a custom little icon in the upper left of the app window


Leave a comment

What color are brown eyes? (spam prevention)
Code under MIT License unless otherwise indicated.
© 2020, Downranked, LLC.