wx.grid.GridCellBoolRenderer and my owen Renderers

Hello

I’ve got a Problem when i combinate the wx.grid.GridCellBoolRenderer and a renderer from myself.

When i combinate them the value in the cell (who my renderer should showe) is black. But why? When i use only mi Renderer I have no problems???

I attached an Example…

Greeze Micha

gridtest.py (4.87 KB)

Micha Reiser wrote:

Hello

I've got a Problem when i combinate the wx.grid.GridCellBoolRenderer and a renderer from myself.

When i combinate them the value in the cell (who my renderer should showe) is black. But why? When i use only mi Renderer I have no problems???

You don't set the text foreground, and so when you also use the wx.grid.GridCellBoolRenderer it probably leaves the DC without a text foreground set, or sets it to black or something. If your renderer sets all the DC attributes that it needs then it works as expected.

     def Draw( self, grid, attr, dc, rect, row, col, isSelected ):
         table = grid.GetTable()
         val = str(table.GetValue(row, col))
         hAlign, vAlign = attr.GetAlignment()
         dc.SetFont( attr.GetFont() )
         if isSelected:
             dc.SetBrush(wx.Brush( grid.GetSelectionBackground(), wx.SOLID))
             dc.SetTextForeground(grid.GetSelectionForeground())
             dc.SetTextBackground(grid.GetSelectionBackground())

         else:
             dc.SetBrush( wx.Brush( attr.GetBackgroundColour(), wx.SOLID ) )
             dc.SetTextForeground(attr.GetTextColour())
             dc.SetTextBackground(attr.GetBackgroundColour())
         dc.SetPen( wx.TRANSPARENT_PEN )
         dc.DrawRectangleRect( rect )
         print rect
         grid.DrawTextRectangle( dc, val, rect, hAlign, vAlign )

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!