[pygtk] How to change alternating row background colors in a gtk.TreeView?

Wes Hansen wes at ridersdiscount.com
Tue Jan 31 04:40:40 WST 2012


Hello,

I'm attempting to change the alternating row background color in a
gtk.TreeView. I am aware that this sort of styling should not be
overridden and should be left up to the theme and that a treeview's
settings can be updated through data added to a treemodel. But I am
also aware that it is possible to override these styles through the
use of gtkrc files and strings. In my case, I've created a string that
looks like this:

gtk.rc_parse_string( """
style "custom-treestyle"{
	GtkTreeView::allow-rules = 1
	GtkTreeView::even-row-color = "#90EE90"
	GtkTreeView::odd-row-color = "#00CBFF"
}
widget "*custom_treeview*" style "custom-treestyle"
""")

treeview.set_name( "custom_treeview" )

This should give me the intended style: A GtkTreeView that contains
alternating background row colors.  But instead, it sets every row's
background color to the color specified by 'even-row-color'.
What am I doing wrong?

Thanks in advance,

Wes


More information about the pygtk mailing list