[pygtk] Bold-Face line in a TreeView with glib2.10
Brian
dol-sen at telus.net
Sun May 28 00:01:04 WST 2006
On Sat, 2006-27-05 at 15:26 +0200, Nemesis wrote:
> Hi all,
> I'm experimenting a strange behaviour with newer gtk release (the ones
> with glib >2.10).
> I need to set some lines in a treeview in bold-face and some not. So I
> set the textrenderer property "weight" to pango.FONT_WEIGHT and the I
> use row by row the property "weight-set" to select wich row must be
> in bold face.
> This approach is not working with newer gtk releases, the bold face is
> not set, if there is at least one row with the property "weight-set"
> set to False.
>
> I read that Sylpheed-Claws had the same problem and they fixed it by
> setting row by row the weight property. I could fix my application in
> the same way but I'd like to know if this is a GTK bug or I'm using in
> the wrong way the "weight" and "weight-set" properties.
> What do you think?
>
It's working for my app just fine. Currently at glib-2.10.2
some snipits:
# add the text renderer
text = gtk.CellRendererText()
self._column.pack_start(text, expand = True)
self._column.add_attribute(text, "text", 0)
self._column.set_cell_data_func(text, self.cell_data_func, None)
def cell_data_func(self, column, renderer, model, iter, data):
"""function to render the package name according
to whether it is in the world file or not"""
#full_name = model.get_value(iter, 0)
color = model.get_value(iter, 5)
if model.get_value(iter, 4):
renderer.set_property("weight", pango.WEIGHT_BOLD)
else:
renderer.set_property("weight", pango.WEIGHT_NORMAL)
if color:
#if color == 'blue':
renderer.set_property("foreground", color)
#else:
# renderer.set_property("background", color)
else:
renderer.set_property("foreground-set", False)
#renderer.set_property("background-set", False)
#renderer.set_property("text", full_name)
--
Brian <dol-sen at telus.net>
More information about the pygtk
mailing list