我用PyGTK实现了一个带有以下代码的GUI:
swin = gtk.ScrolledWindow()
swin.set_shadow_type(gtk.SHADOW_ETCHED_IN)
self.lstore = gtk.ListStore(str, str, str, str, str, str)
self.tree = gtk.TreeView(self.lstore)
for i in range(6):
row = gtk.CellRendererText()
cell = gtk.TreeViewColumn("Arg %d" % i, row, text=0)
self.tree.append_column(cell)
swin.add(self.tree)
self.lstore.append(['a', 'b', 'c', 'd', 'e', 'f']) #Add new record.
但它显示了具有相同值的新记录:
答案 0 :(得分:1)
问题在于
cell = gtk.TreeViewColumn("Arg %d" % i, row, text=0)
告诉所有单元格显示第0列的文本。您可能需要
cell = gtk.TreeViewColumn("Arg %d" % i, row, text=i)