简体   繁体   English

tkinter中是否有任何选项可以更改任务栏图标?

[英]Is there any option in tkinter to change the taskbar Icon?

I'm new in tkinter. 我是tkinter的新手。 I am trying to change the icon of the Tkinter window but it's change only the icon of the top title bar in the window, But I'm also want to change the icon which is present in the taskbar. 我正在尝试更改Tkinter窗口的图标,但只更改了窗口顶部标题栏的图标,但是我也想更改任务栏中显示的图标。 Is there any way to solve it? 有什么办法解决吗?

root.wm_iconbitmap(r'C:\Users\Jawad Saqib\Desktop\Desktop\Python\jawad.ico')

No, 没有,

you can like make it to an exe and then also give it an taskbar icon but, because the python is executed in a python launcher it wil not can changed trough code. 您可以将其设置为exe ,然后为其指定任务栏图标,但是由于python是在python启动器中执行的,因此无法更改谷歌代码。

To change the icon displayed in the actual window, (assuming root is the Tk() instance, you run root.iconbitmap(icon) . 要更改实际窗口中显示的图标,(假设root是Tk()实例,请运行root.iconbitmap(icon)

To change the icon displayed in the taskbar, you'd need to compile to code into exe or your system executable and set an icon, because the icon in the taskbar is the exe that's running. 要更改任务栏中显示的图标,您需要进行编译以将其编码为exe或系统可执行文件,并设置一个图标,因为任务栏中的图标是正在运行的exe。 In this case, the executable that is running is python, and it is displaying the python icon. 在这种情况下,正在运行的可执行文件是python,并且正在显示python图标。 Or the tkinter icon - it varies on platform. 或tkinter图标-在平台上有所不同。

Eg. 例如。 pyinstaller --icon=icon.ico myscript.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM