[pygtk] Enabling markup for a TreeViewColumn
Bryant Huang
735115 at gmail.com
Wed Mar 7 11:30:37 WST 2007
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-CellRenderer=
TextMarkupbut
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 =3D "my.glade"
self.widget_tree =3D gtk.glade.XML(self.glade_fn)
self.treeview_results =3D self.widget_tree.get_widget("treeview_results")
# create results list view
self.liststore_results =3D 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 =3D gtk.CellRendererText()
column =3D gtk.TreeViewColumn(title, renderer, text=3Dcolumn_id, markup=
=3D0)
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=3D\"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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20070306/7513e522/at=
tachment.htm
More information about the pygtk
mailing list