Home > front end >  Display a png (or ico) as icon in the windows taskbar
Display a png (or ico) as icon in the windows taskbar

Time:10-17

I have an image and I would like that to make my python program (tkinter GUI) visualize it as an icon in the Windows taskbar, how can I do that?

CodePudding user response:

icon = tk.PhotoImage(file="icon.png")
root.iconphoto(True, icon)

Note that this only handles 1 of the 2 icon locations, the icon for the file needs to be set in windows explorer.

CodePudding user response:

I think you cannot do that when the file is a .py. It needs to be an executable.

https://www.geeksforgeeks.org/convert-python-script-to-exe-file/

Open any terminal (like cmd, WT or PS) and along with the other pyinstaller flags, add --icon="path_to_icon.ico"

Example:

pyinstaller my_program.py --icon="icon.ico"
  • Related