[pygtk] treeview markup entries and interactive search

Tim Evans t.evans at aranz.com
Thu Aug 21 07:21:46 WST 2008

Tasos Latsas wrote:
> I tried it but unfortunately the normal and bold entries are in the same
> column, so I need the tags...:( Looks like I'll use the extra-column
> solution..
> Thanx anyway!!
> Tim Evans wrote:
>> gtk.CellRendererText has separate properties for changing font
>> attributes.  In the case you describe you would set the "weight"
>> property to pango.WEIGHT_BOLD and just use "text" rather than "markup".
>> Unless you need to change the font attributes mid-way through the text
>> using the specific attributes will be a little faster than markup and
>> won't interfere with searching.

Sorry, I think I didn't explain that very well.  Here's an example instead:

   model = gtk.ListStore(str, int)
   model.append(('home', pango.WEIGHT_NORMAL))
   model.append(('work', pango.WEIGHT_BOLD))
   view = gtk.TreeView(model)
   view.insert_column_with_attributes(0, 'Title', gtk.CellRendererText(),
                                      text=0, weight=1)

The first *model column* is the text, the second is the font weight. 
The *view* contains only a single column, but it's attached to both 
model columns to set the text and weight used by the cell renderer.

Tim Evans
Applied Research Associates NZ

More information about the pygtk mailing list