#!/usr/bin/python
# -*- coding: utf8 -*-import gtk
ls = gtk.ListStore(str, str, str)
tv = gtk.TreeView(ls)
tv.show()
ls.append(["text", "red", "item 1"])
ls.append(["text", "gray30", "item 2"])
ls.append(["text", "black", "item 3"])
ls.append(["text", "blue", "item 4"])
ls.append(["text", "yellow", "item 5"])
ls.append(["text", "green", "item 6"])
# method 1 -- special column
cr1 = gtk.CellRendererText()
col1 = gtk.TreeViewColumn("col 1", cr1, text=0, foreground=1)
# method 2 -- data function
cr2 = gtk.CellRendererText()
col2 = gtk.TreeViewColumn("col 2", cr2, text=2)
def func(col, cr, model, iter, data):
if int(model[iter][2][-1:]) in range(3, 5):
cr.set_property("foreground", "blue")
else:
cr.set_property("foreground-set", False)
col2.set_cell_data_func(cr2, func, None)
tv.append_column(col1)
tv.append_column(col2)
window = gtk.Window()
window.connect("destroy", lambda w: gtk.main_quit())
window.set_default_size(400, 300)
window.add(tv)
window.show()
gtk.main()
-----------------------------------------
мельком глянул в мануал -- в сях вроде бы так же должно выглядеть
хопе хелпс)