2024-09-19 20:35:17 发布
网友
我用Python创建了一个简单的聊天框,我想在一个TKinter文本小部件中插入一个图像(图释)。我用这个代码试过了:
img = Image.open("icon.jpg") self.bigText.insert(END, img) # bigText is the text widget
上面代码的输出是
而不是图像。在
我不是百分之百确定,但我认为你需要使用^{}。比如:
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
我不是百分之百确定,但我认为你需要使用^{} 。比如:
应该会成功的。在
我用的是:
相关问题 更多 >
编程相关推荐