The hint below was helpful and let me try different approaches, but my attempts have failed. In my grid I am adding/deleting rows where each cell may have a different span (and various other attrs).
First, I tried setting each cell with a different instance of the same custom renderer class. The setting alone took minutes and I abandoned that approach.
Second, I tried setting the default renderer to my custom renderer. The intent was for the Draw method to read the cell contents, pull in format data from a dictionary based on the key in the cell, and render. Setting the renderer is fast, and the renderer _*init*_ goes through, but the Draw method never gets entered when scrolling/resizing (and there IS text in the cells!). Don't understand why this fails. If this approach is to be successful, there are some accelerator techniques that can be added (e.g. exit Draw if cell remains empty; take the dict key from an array instead of via GetCellContents).
Someone out there must have been through this...have you found it best to set renderers ONLY for cells with data? If so, what is the best way to reassign renderers upon row add/delete? Perhaps cycling through cell attrs as one part of the demo shows? The concern is performance...this app has some logic which adds/deletes rows automatically depending on whether the user attempts to a task on top of another. A built-in method that updates renderers based on row/col insert/delete might be a good feature sometime.
Cheers and Thanks, Chris Stone
> Robin, is there any snippet or demo showing spanning (size) used in a DC?
>
Make this change in the demo and you'll see that the custom renderer
will automatically paint the whole (spanned) cell.
Index: wxPython/demo/GridStdEdRend.py
<details class='elided'>
<summary title='Show trimmed content'>···</summary>
===================================================================
RCS file:
/pack/cvsroots/wxwidgets/wxWidgets/wxPython/demo/GridStdEdRend.py,v
retrieving revision 1.10
diff -u -4 -r1.10 GridStdEdRend.py
--- wxPython/demo/GridStdEdRend.py 2004/05/02 02:41:33 1.10
+++ wxPython/demo/GridStdEdRend.py 2004/08/05 23:14:34
@@ -112,8 +112,10 @@
renderer = renderClass(*args)
self.SetCellValue(row, renCol, label)
self.SetCellValue(row, renCol+1, value)
self.SetCellRenderer(row, renCol+1, renderer)
+ if label == 'MyCustomRenderer':
+ self.SetCellSize(row, renCol+1, 2, 2)
row = row + 2
row = 2
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!