PyGridCellRenderer: different background colors with/out a rectangle around a cell.

Hi All!

I created a custom grid cell renderer.
Everything is fine except a background color: bg color for selected cells isn’t same in different selections cases(see screen shots).
So here is my questions:

  1. How to implement a logic for same bg color? Should I define my renderer for every cell to solve it?
  2. Can I define a system bg color and not hard code it?
···

Thanks.
Daniel

Pic(1) - row selected, no rectangle:
Pic(2) - range selected:
Pic(3) - row selected (rectangle presents):

Daniel Leybovich wrote:

Hi All!

I created a custom grid cell renderer.
Everything is fine except a background color: bg color for selected
cells isn't same in different selections cases(see screen shots).
So here is my questions:

1. How to implement a logic for same bg color? Should I define my
    renderer for every cell to solve it?
2. Can I define a system bg color and not hard code it?

The renderer's Draw method receives the selection state of the cell in the isSelected parameter, and you can use grid.GetSelectionBackground to get the colour that should be used for drawing a selected cell.

···

--
Robin Dunn
Software Craftsman

Hi Robin!

you can use grid.GetSelectionBackground
Thanks(it works) and sorry, I will give a more attention to Grid API :frowning:

Daniel.

Hi!

Unfortunately id doesn’t work when no Cursor(I tried to play with Cursor, and didn’t find a way how to fix it) :frowning:
For example I defined a green color for bg:

self.grid.SetSelectionBackground(wx.GREEN)

and by Robin suggestion I defined a bg for renderer:

**def** Draw(self, grid, attr, dc, rect, row, col, isSelected):
    color = grid.GetSelectionBackground()
    if isSelected:
        dc.SetBrush(wx.Brush(color, wx.SOLID))

Thanks.
Daniel

Col selected, cursor not presents: