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:
How to implement a logic for same bg color? Should I define my renderer for every cell to solve it?
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):
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.
Unfortunately id doesn’t work when no Cursor(I tried to play with Cursor, and didn’t find a way how to fix it)
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))