Я пытаюсь добавить пользовательский GdkPixbuf в ListStore, чтобы распечатать другое изображение (если оно предусмотрено моделью) или изображение по умолчанию .
listmodel = Gtk.ListStore(str, str, str, GdkPixbuf.Pixbuf)
datos = model.Workouts
myDir = os.getcwd()
for i in range(len(datos)):
renderer_pixbuf = Gtk.CellRendererPixbuf()
#If model provides a image, we use it, otherwise we're using a default one.
if datos[i].get_image():
imageDir = str(myDir + '/ipm1920-p1/images/' + datos[i].get_id())
f = open(imageDir, mode='wb+')
f.write(base64.b64decode(datos[i].get_image()))
else:
imageDir = str(myDir + '/ipm1920-p1/images/empty.jpg')
#Creating the buffer from the image on disk
renderer_pixbuf.props.pixbuf = GdkPixbuf.Pixbuf.new_from_file(imageDir)
#Appending it
fila = [datos[i].get_publishDate(), datos[i].get_name(), str(datos[i].get_description()),renderer_pixbuf]
listmodel.append(fila)
# a treeview to see the data stored in the model
view = Gtk.TreeView(model=listmodel)
# for each column
for i, column in enumerate(columns):
#...other columns definition omited
#Cell with image
imagecell = Gtk.CellRendererPixbuf()
col = Gtk.TreeViewColumn("Image", imagecell)
col.add_attribute(imagecell, "pixbuf", 3)
view.append_column(col)
Я собираюсь:
RuntimeWarning: ожидается маршалирование заимствованной ссылки для , но ничто в Python не содержит ссылку на этот объект. См.: https://bugzilla.gnome.org/show_bug.cgi?id=687522< /а>
Как я могу предоставить pixbufer в ListStore, чтобы иметь возможность распечатать его?