Python将图像插入Tkinter文本小部件
我正在用Python创建一个简单的聊天框,我想在TKinter文本小部件中插入一个图像(表情符号)。我已使用以下代码进行了尝试:Python将图像插入Tkinter文本小部件,python,tkinter,python-imaging-library,Python,Tkinter,Python Imaging Library,我正在用Python创建一个简单的聊天框,我想在TKinter文本小部件中插入一个图像(表情符号)。我已使用以下代码进行了尝试: img = Image.open("icon.jpg") self.bigText.insert(END, img) # bigText is the text widget 上面代码的输出是 <PIL.JpegImagePlugin.JpegImageFile instance at 0x01AB5A30> 而不是图像。我不是100%确定,但我
img = Image.open("icon.jpg")
self.bigText.insert(END, img) # bigText is the text widget
上面代码的输出是
<PIL.JpegImagePlugin.JpegImageFile instance at 0x01AB5A30>
而不是图像。我不是100%确定,但我认为您需要使用。比如:
self.bigText.image_create(END, image=img)
我应该做到这一点。我是通过以下方法实现的:
from Tkinter import *
from PIL import Image, ImageTk
self.myEmoticons.append(self.smiley)
self.bigText.image_create(END,image = self.myEmoticons[self.myEmoticonsCtr])
self.myEmoticonsCtr=self.myEmoticonsCtr + 1
如果不行,我们就得等@BryanOakley出现——他是这些地区的常驻Tk/Tkinter专家。剩下的呢?您能否提供一个完整的、最低限度的工作实现示例?