我有一个简单的图标视图小工具,从商店读取pixbuf。我想缩放像素,所以我使用了iconview`s的set_cell_data_func。但是有一个问题。它只为一行调用了9次,并且运行速度更慢,甚至flowbox
self.iconmodel = Gtk.ListStore(GdkPixbuf.Pixbuf)
self.icon = Gtk.IconView()
self.icon.set_model(self.iconmodel)
self.icon.set_pixbuf_column(0)
self.icon.set_cell_data_func(self.icon.get_cells()[0], self.custom_cell_function, None)
def custom_cell_function(self, cell_layout, cell, tree_model, tree_iter, data):
p = tree_model[tree_iter][0]
p = p.scale_simple(p.get_width()*0.33, p.get_height()*0.33, 1)
cell.set_property('pixbuf', p)在图片中,商店中有127个像素,并调用func 989次:) Flowbox似乎比图标视图更适合,但所有拇指必须是小部件,而不是单元格渲染器。
你们有什么办法减少它吗?谢谢。exmp
发布于 2017-03-12 08:31:21
我发现你的列表存储中没有添加任何pixbufs。也许你可以直接写:
# for p in your_pixbufs
p = p.scale_simple(p.get_width()*0.33, p.get_height()*0.33, 1)
self.iconmodel.append( [p] )而不是cell_data_func
https://stackoverflow.com/questions/40071478
复制相似问题