简体   繁体   English

Windows 任务栏中的错误 Tkinter 图标

[英]Wrong Tkinter icon in Windows Taskbar

I've set the icon I want to use with root.iconbitmap( default='Test.ico') and the icon appears correctly in the Tkinter GUI, but it shows the 'Tkinter feather' logo in the Windows Taskbar.我已经设置了我想与root.iconbitmap( default='Test.ico')的图标,并且该图标在 Tkinter GUI 中正确显示,但它在 Windows 任务栏中显示了“Tkinter Feather”徽标。 When I compile the python scripts with cx_freeze, the .exe file has the correct icon, but again, the icon in the Taskbar shows the feather.当我用 cx_freeze 编译 python 脚本时,.exe 文件有正确的图标,但同样,任务栏中的图标显示羽毛。 Is there any way to fix this?有没有办法解决这个问题? Thanks in advance.提前致谢。

PS I'm using Python 3.6.3 PS我使用的是Python 3.6.3

EDIT:编辑:

The tkinter window shows the correct icon, the issue is that the Taskbar shows the 'feather' icon. tkinter 窗口显示了正确的图标,问题是任务栏显示了“羽毛”图标。 Task Manager shows the correct icon for some reason.由于某种原因,任务管理器显示正确的图标。 Strangely enough, sometimes the Taskbar shows the correct icon after a while.奇怪的是,有时任务栏会在一段时间后显示正确的图标。 I haven't been able to reproduce this as it seems to occur randomly.我无法重现它,因为它似乎是随机发生的。

I used Inno Setup ( http://www.jrsoftware.org/isinfo.php ) to bundle the .exe with the relevant files.我使用 Inno Setup ( http://www.jrsoftware.org/isinfo.php ) 将 .exe 与相关文件捆绑在一起。 This fixed the icon not appearing, as well as reducing the download size for my application from 300MB to 70MB.这修复了没有出现的图标,并将我的应用程序的下载大小从 300MB 减少到 70MB。

Try adding the full path of the icon file.尝试添加图标文件的完整路径。 It is because only your python script ie in the same directory can find that icon file hence showing it on top of window but not in task manager.这是因为只有您的python 脚本,即在同一目录中才能找到该图标文件,因此将其显示在窗口顶部而不是任务管理器中。

something like this :像这样:

from tkinter import *
login=Tk()


login.iconbitmap(r'C:\Users\Desktop\PYTHON\GUI\cricket.ico')

This works for me这对我有用

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

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