Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the application and taskbar icon - Python/Tkinter

Tags:

python

tkinter

I've been working on a very simple python/tkinter script (a .pyw file) and I'd like to change it's application icon (the 'file' icon shown at the explorer window and the start/all programs window, for example - not the 'file type' icon nor the main window of the app icon) and the taskbar icon (the icon shown at the taskbar when the application is minimized). Is it possible to change them or is it something only doable when you effectively install an application through an .exe?

This little app is supposed to run on Windows XP / 7 machines only and it's in Python 2.7.3.

Thanks in advance!

like image 634
bernardo.g Avatar asked Feb 15 '13 17:02

bernardo.g


2 Answers

Another option on Windows would be the following:

To your python code add the following:

import ctypes

myappid = 'mycompany.myproduct.subproduct.version' # arbitrary string
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
like image 73
user5734223 Avatar answered Nov 15 '22 15:11

user5734223


Use

root.iconbitmap(default='ardulan.ico')

But the probleme is that it only replace the icon on the windows not on the taskbar. It's because the py file is executed from python interpreter so windows use his icon and not the tkinter icon.

You have to 'compile' it i think with py2exe, cx_Freeze, py2app ...

http://www.py2exe.org/index.cgi/CustomIcons

like image 44
user2740652 Avatar answered Nov 15 '22 14:11

user2740652