[wxPython-users] wxGrid: difference between Renderer and Editor

Paul McNett p at ulmcnett.com
Thu May 3 12:31:14 PDT 2007


DomDom wrote:
> 1)A silly question: I don't really understand the difference between a 
> renderer and an editor in a wxGrid.
> Can anybody tell me the difference and when to use them ?

A renderer is what displays the data, and an editor is what is used to 
edit the data in a grid cell. When viewing the grid, you see a number of 
rows and a number of columns. Each one of those cells was drawn using a 
renderer. They could be the same renderer for all of them, the same for 
a column, or different for every cell.

Only when in edit mode for a cell does the editor come into play. It 
acts more like a standard widget and lets you e.g. type some text in or 
click a checkbox.


> 2)Additionally, when I run a small grid program, everything works fine 
> on a pc but on a mac (osx), the figures can only be typed with the 
> keyboard, not with the numeric pad. I had a look at the demo file 
> GridCustEditor.py where the num pad works fine on the mac. But I don't 
> really understand why... I think an answer to 1) would answer 2) as well...

Editors in particular are really quite difficult to get right in 
wxPython... I had a hell of a time getting them set up to reliably not 
segfault. If you are thinking of using wx.Grid to display columnar data 
(e.g. from a database) then please take a look at Dabo's dGrid, as we've 
put a lot of work into that sucker to make it much easier to work with 
than the raw wx.Grid. You don't need to know about GridTables, or even 
editors and renderers as these are taken care of for you 
semi-automatically.

-- 
pkm ~ http://paulmcnett.com




More information about the wxpython-users mailing list