[pygtk] How to change CellRendererToggle's background color

Mauricio Tellez mauricio.tellez at gmail.com
Wed Aug 16 23:11:26 WST 2006


Well, thanks to John, now It works. As he said, the key is cell-background.
The problem I had was that if I use:

   my_render =3D gtk.CellRendererText() # or CellRendererToggle()
   my_renderer.set_attribute('cell-background', my-color)

It paint all the column, not the cell I want, but If I tried to do something
like this:

   my_col =3D gtk.TreeViewColumn('my title', my_render,
cell-background=3Dmy_color)
or this:
   my_col.set_attribute(my_render, cell-background=3Dmy_color)
I get an error, so, to make it work, I need to:

   my_col =3D gtk.TreeViewColumn('my title', my_render)
   my_col.add_attribute(my_render, 'cell-background', x)

where x my model's column with the color I want for each cell. Hope this
help someone.

2006/8/15, John Finlay <finlay en moeraki.com>:
>
> Mauricio Tellez wrote:
> > Hi, I have a TreeView with 4 columns, the first and second has
> > CellRendererText and the thirth and fourth are CellRendererToggle.
> > When the user modify the value of any cell, I want to change the row's
> > background color. For the CellRendererText I use something like this:
> >
> > myRender =3D gtk.CellRendererText()
> > myCol =3D gtk.TreeViewColumn('My title', myRender, text=3Dx, background=
=3Dy)
> >
> > this work fine and my cell is colored, but when I tried this:
> >
> > myRender =3D gtk.CellRendererToggle ()
> > myCol =3D gtk.TreeViewColumn('My title', my Render, active=3Dv,
> > activatable=3Dw, background=3Dz)
> >
> > pygtk complains that CellRendererToggle don't have a background
> > property. So my first 2 columns are colored but the last 2 don't. How
> > can I fix this?
> Try using the "cell-background" property
>
> John
>



-- =

Mauricio Tellez
------------ pr=F3xima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20060816/2fa91b25/at=
tachment.htm


More information about the pygtk mailing list