大神们指教:
我是用pillow在label里显示图片。
单独进行显示时没有问题,而当我把label定义在一个函数里用botton调用时却显示不出。
def xianshi():
i=entry.get()
s = r'D:\\1.jpg' # jpg图片文件名 和 路径。
im = Image.open(s)
tkimg = ImageTk.PhotoImage(im) # 执行此函数之前, Tk() 必须已经实例化。
label = tk.Label(root, image=tkimg)
label.pack()
botton=tk.Button(root,text='点击显示图片',command=xianshi)
botton.pack()