Hello,

I've spent the last 3 hours trying to figure out how to highlight text in a
TreeView cell. I found the example at
http://www.pygtk.org/pygtk2tutorial/sec-CellRenderers.html#sec-CellRendererTextMarkupbut
have been unable to replicate the same behavior in my own project.

Here are the relevant excerpts from my code, simplified slightly:

# get object from Glade
self.glade_fn = "my.glade"
self.widget_tree = gtk.glade.XML(self.glade_fn)
self.treeview_results = self.widget_tree.get_widget("treeview_results")

# create results list view
self.liststore_results = gtk.ListStore(int, str)
self.treeview_results.set_model(self.liststore_results)
self.add_results_column("Number", 0)
self.add_results_column("Text", 1)
self.liststore_results.set_sort_column_id(0, gtk.SORT_ASCENDING)

def add_results_column(self, title, column_id):
   """Add a column to the results list view."""
   renderer = gtk.CellRendererText()
   column = gtk.TreeViewColumn(title, renderer, text=column_id, markup=0)
   column.set_resizable(True)
   column.set_sort_column_id(column_id)
   self.treeview_results.append_column(column)

# insert rows into results list view
for i in range(10):
   self.liststore_results.append([i, "I say <span
background=\"yellow\">hello world</span>"])

Basically, I want Pango markup to be enabled for the right column so that
only the string "hello world" would have a yellow background. However, this
<span>...</span> string is not being rendered, so it passes through as is.

What am I doing incorrectly? I've tried this on Fedora Core 3 and 4 with the
same results.

Thanks in advance,
Bryant
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to