<分区>
我想用我自己的替换 Tkinter 图标,但其他问题的答案无济于事。在同一文件夹中,我将我的脚本和使用 Paint 创建的图像保存为 icon.png
。这是脚本:
from Tkinter import *
root = Tk()
icon = PhotoImage(file='icon.png')
root.tk.call('wm', 'iconphoto', root._w, icon)
root.mainloop()
这个错误是由 root.tk.call 方法引起的:
TclError: couldn't recognize data in image file "icon.png"