Estoy creando un cuadro de chat simple en Python y quiero insertar una imagen (emoticones) en un widget de texto TKinter. Lo he probado usando este código:
img = Image.open("icon.jpg") self.bigText.insert(END, img) # bigText is the text widget
La salida del código anterior es
En lugar de la imagen.
No estoy 100% seguro de esto, pero creo que necesitas usar image_create
. Algo como:
self.bigText.image_create(END, image=img)
debe hacer el truco
Lo he hecho usando:
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