win10的Python 3 tkinter iconbitmap错误

释放双眼,带上耳机,听听看~!
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 you 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()
PS E:\py-program\ppe4> python tkinter103.py
Traceback (most recent call last):
  File "tkinter103.py", line 9, in <module>
    top.iconbitmap('py-blue-trans-out.ico')
  File "C:\Users\Administrator\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
from tkinter import *
from tkinter.messagebox import showinfo

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

top = Tk()
#img = PhotoImage(file='py-blue-trans-out.ico') #no

top.title('Echo')
top.iconbitmap('@tool.xbm') #yes
#top.iconphoto(True, PhotoImage(file='tool.xbm')) #no

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()

人已赞赏
Python

mac设置python版本切换,和设置python默认版本

2019-3-19 9:48:58

Python

Mac设置默认python版本

2019-4-20 23:47:31

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索