[pygtk] Change background of selected cell in a TreeView

Noam Yorav-Raphael noamraph at gmail.com
Tue Jun 30 01:15:19 WST 2009


Hello,

TreeViews usually highlight the background of the selected cell. I
would like to change that color to white (the background of unselected
cells), so that a border would be drawn around the cell but its
background won't change.

I tried using treeview.modify_bg(gtk.STATE_SELECTED,
gdk.color_parse('white')), but it had no effect.

Do you have any idea how to do it?

If you are interested, the long story is that I write an IDE - a code
editor which can show a list of completions. If the user requested the
completion list to be shown, pressing enter will copy the selected
item to his text. But the list can also be shown automatically, after
a dot was inserted, and then I don't want Enter to do anything
special, because maybe the user didn't intend to complete from the
list at all. If the user moves around the list to select what he
wants, pressing Enter will of course copy the selected item to the
text. To distinguish between those two states, I would like to use the
selection background.

Thanks,

Noam


More information about the pygtk mailing list