Changing the application and taskbar icon - Python/Tkinter

后端 未结 5 2134
眼角桃花
眼角桃花 2020-12-17 17:12

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 th

5条回答
  •  天命终不由人
    2020-12-17 17:35

    You can do that by creating a new shortcut to the python.exe or pythonw.exe file, (option available in Window's explorer right-click menu), then right click the shortcut, select properties, and change target to:

    "C:\Path\to\Python.exe" "Absolute\or\relative\path\to\file.py"
    

    Then select change icon (still in the properties window), and select your .ico file. Executing the program from this shortcut will automaticaly set the selected icon as taskbar and window icon.

    Note though that by executing set shortcut, instead of clicking directly your .py file, the current working directory will be the one of python.exe, and not of your file, you can change that too in the shortcut's properties window, in the "start in" entry field (underneath target), or by using the python methods os.getcwd() to find the current working directory and os.chdir(path) to set it

提交回复
热议问题