I am developing a game in Python and was wondering how to give it its own icon. I am using a windows computer and have no extra things installed with Python. Oh also I am using version 3.3 Is this even possible.
P.S I have found other things on Stack Overflow but they are using different Operating Systems like Ubuntu and Macintosh
ico file back. To change the icon that the .exe has, you can pass the --icon=icon. ico to the pyi-makespec command or modify the . spec file yourself by altering the exe object to add the argument icon='icon.
Use the --icon argument to specify a custom icon for the application. It will be copied into the Resources folder. (If you do not specify an icon file, PyInstaller supplies a file icon-windowed. icns with the PyInstaller logo.)
Right-click the script and select create a shortcut. Right-click the new shortcut and select properties. Under the shortcut tab, note the target option.
If you wish to create a new Python application, you must specify the Python version, fill in the Application root, and the Application URL. Then click Create. Optionally, you can also set up Application startup file, Application Entry point and Passenger log file.
There are two steps: first build the Python executable. For this you will need something like py2exe, "which converts Python scripts into executable Windows programs, able to run without requiring a Python installation."
Then once you have your executable, to give it an icon, you can use the answer to this question: Add icon to existing EXE file from the command line for that finishing touch.
You can't add a custom icon to a plain Python script, but if you convert it to a Windows executable using py2exe, you can specify icon resources to use for it. There's a how-to on their wiki.
Update (2021-11-3):
Py2Exe new versions are now available so @dmitris's solution will now work although PyInstaller is another option. However the Python 3.5 series of Py2Exe ended on September 30, 2020.
Original Answer:
@dmitri's solution works but Py2Exe stopped development at python 3.4 and will not work with newer versions PyInstaller would also do this.
pip install pyinstaller
pyinstaller --onefile --windowed --icon=youricon.ico yourprogram.py
Python version 3.7.3.
If you are trying to change the icon of the shortcut for your program,
then you need to get to the file where ever it is right-click it and go to create a shortcut
then drag that shortcut to your desktop
then right-click that shortcut and click properties
then click on "Change Icon"
then go to where your desire .ico image is saved and set that as the icon
if you do this and you open your program in the corner will be the .ico you selected and on your desktop, it will show the icon instead of the python image.
that is how you change the shortcut icon but there is no way to change the actual window icon in the corner unless you're using something like Tk or Pygame.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With