.exe Icon Doesn't Change [py2exe]
Solution 1:
It appears py2exe has a 4-year-old bug on handling icons, but due to its description, I managed to make this workaround:
setup_dict = dict(
windows = [{'script': "script.py",
"icon_resources": [(1, "icon.ico")}],
)
setup(**setup_dict)
setup(**setup_dict)
This pretty much builds the project twice. If your project is complex and takes too long to process through py2exe, you can use this to build a dummy py file:
import tempfile
tf = tempfile.NamedTemporaryFile(delete=False)
tf.close()
setup(
windows = [{
'script': tf.name,
"icon_resources":[(1, "icon.ico")]}]
)
os.remove(tf.name)
Just don't forget to set excludes like your project, otherwise you will get your dist
folder cluttered with unwanted files.
Solution 2:
Please try this
from distutils.core import setup
setup(
options = {'py2exe': {'bundle_files': 1}},
zipfile = None,
windows = [{
"script":"myproject.py",
"icon_resources": [(1, "favicon.ico")],
}],
)
Solution 3:
I handled my problem like that;
- I used the above code which I post in my question.
- Then I installed Resourch Hacker program.
- I opened myprogram.exe file with Resourch Hacker program.
- Then Action > Replace Icon > I choosed the icon which I want.
- And its ok!
For Resourch Hacker tutorial CLICK THIS
Solution 4:
I meet the same problem. I have solved it by download a win7 icon from http://www.iconarchive.com/search?q=windows+7&page=5, and the reason should be the icon file that could not work at the very start is not a correct win7 format icon.
this web page https://www.creativefreedom.co.uk/icon-designers-blog/windows-7-icon-sizes/ tells us a topic "Testing your Windows 7 Icon" to check whether a icon is a really win7 icon.
Solution 5:
I used a different program, came accross pyinstaller from this post and it worked first time.
Installed it:
pip install pyinstaller
Compiled my program:
pyinstaller myprogram.py -i icon.ico
Worked first time! Hope that helps.
Post a Comment for ".exe Icon Doesn't Change [py2exe]"