On Tuesday, November 30, 2010 03:09:44 pm Ed Leafe wrote:
> On Nov 30, 2010, at 5:56 PM, Paul McNett wrote:
> > I've only implemented 2 dynamic properties that will work row by row
> > (DynamicCellBackColor and DynamicCellForeColor). Here's how to get the
> > text coloring working:
> >
> > http://codepad.org/EEiqrd6S
> >
> > Stay tuned and I'll have the DynamicCellFontBold property added to
> > subversion (give me a few minutes).
>
> I was just trying to get this working, and I found a problem: the
> dynamic
> cell properties work great when you refer to the bizobj for the value, but
> in non-bizobj grids, such as the sample grid, it causes an infinite loop
> if you try grid.getValue() for the cell! We call both
> _updateDynamicProps() and _updateCellDynamicProps() on the column object
> every time we call the overridden GetValue(), since that's required for
> virtual grids to display dynamic properties. But if the dynamic method
> needs to call grid.getValue() for the cell in order to determine what to
> return, well, you can see the problem.
>
> I'm going to see about putting in a bypass from direct getValue() calls,
> since the only time we should need GetValue() to update the dynamic stuff
> is when it's coming from the wx layer.
>
>
>
> -- Ed Leafe
I always thought that dynamic stuff was not the way to go for grids - I think
I got this impression from Ed's comments to me in the past. I also believe he
told me to use a CustomRenderClass. I could also work at the cell level and
not just the column.
some_column.CustomRendererClass = PrintRedGreenBoolRenderer
class PrintRedGreenBoolRenderer(wx.grid.PyGridCellRenderer):
def Draw(self, grid, attr, dc, rect, row, col, isSelected):
text = myval = grid.GetCellValue(row, col)
if myval == 'UNPRINTED':
bg = "yellow"
fg = 'black'
else:
bg = grid.GetBackgroundColour()
fg = 'black'
hAlign, vAlign = attr.GetAlignment()
dc.SetFont( attr.GetFont() )
#if isSelected:
#bg = grid.GetSelectionBackground()
#fg = grid.GetSelectionForeground()
dc.SetTextBackground(bg)
dc.SetTextForeground(fg)
dc.SetBrush(wx.Brush(bg, wx.SOLID))
dc.SetPen(wx.TRANSPARENT_PEN)
dc.DrawRectangleRect(rect)
grid.DrawTextRectangle(dc, text, rect, hAlign, vAlign)
def Clone(self):
return PrintRedGreenBoolRenderer()
Johnf
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message:
http://leafe.com/archives/byMID/[email protected]