gpt4 book ai didi

python - .iconbitmap 给出 TclError : bitmap "*.ico" not defined

转载 作者:行者123 更新时间:2023-12-04 17:41:01 45 4
gpt4 key购买 nike

我正在使用 Tkinter,并且在尝试运行代码时不断收到错误消息,有人可以帮忙吗?

from tkinter import *
from tkinter.messagebox import showinfo

def reply(name):
showinfo(title='Reply', message='Hello %s!' % name)

top = Tk()
top.title('Echo')
top.iconbitmap('py-blue-trans-out.ico')
Label(top, text="Enter your name:").pack(side=TOP)

ent = Entry(top)
ent.pack(side=TOP)
btn = Button(top, text="Submit", command=(lambda: reply(ent.get())))
btn.pack(side=LEFT)
top.mainloop()

我不断收到此错误消息:
Traceback (most recent call last):
File "C:\Users\User\Desktop\manage\tkinter103.py", line 9, in <module>
top.iconbitmap('py-blue-trans-out.ico')
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 1871, in wm_iconbitmap
return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
_tkinter.TclError: bitmap "py-blue-trans-out.ico" not defined

最佳答案

我找到了从终端运行脚本的解决方案。它在那里工作,但是在我的 VS 代码中,我遇到了与您相同的错误。

关于python - .iconbitmap 给出 TclError : bitmap "*.ico" not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54513452/

45 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com