How do I set an application\'s taskbar icon in PyQt4?
I have tried setWindowIcon, and it successfully sets the icon in the top-left of the main window, but it does n
@DamonJW's answer will work, but there is a minor catch: myappid should be unicode (argument type is PCWSTR).
import ctypes
myappid = u'mycompany.myproduct.subproduct.version' # arbitrary string
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
Otherwise getting the AppUserModelID will get wrong unicode characters (祭潣灭湡祭牰摯捵畳灢潲畤瑣瘮牥楳湯
):
import ctypes
from ctypes import wintypes
lpBuffer = wintypes.LPWSTR()
AppUserModelID = ctypes.windll.shell32.GetCurrentProcessExplicitAppUserModelID
AppUserModelID(ctypes.cast(ctypes.byref(lpBuffer), wintypes.LPWSTR))
appid = lpBuffer.value
ctypes.windll.kernel32.LocalFree(lpBuffer)
if appid is not None:
print(appid)
That said, it is a minor thing, since Windows will still recognize the unicode string as "another process" and switch the icon accordingly.