[wxPython] cell editor/renderer question

in trying to learn about wxGrid cell editors and renderers, i abstracted
from the demo code what i thought was a simple testcase with which to
start experimenting:

from wxPython.wx import *
from wxPython.grid import *

if __name__ == '__main__':
   app = wxPySimpleApp()
   f = wxFrame(None, -1, 'simple app')
   f.Show(true)

   g = wxGrid(f, -1)
   g.CreateGrid(5, 5)

   editor = wxGridCellNumberEditor()
   renderer = wxGridCellNumberRenderer()

   attr = wxGridCellAttr()
   attr.SetEditor(editor)
   attr.SetRenderer(renderer)
   g.SetColAttr(0, attr)

   app.MainLoop()

however, this code behaves strangely on my system (wxPython 2.3.2.1 and
Python 2.1.1 under Linux 2.4.2). the last value entered in any cell in
column 0 is automatically entered when i click on any other empty cell
in column 0.

example:

a. enter the value 111 in cell (0,0) and complete the edit with the
enter or tab key
b. click into empty cell (1,0) - the value 111 appears in the cell
c. click into any other empty cell in column 0 - the same thing happens
d. change the value in the current cell to 222
e. click into another empty cell in column 0 - the value 222 appears in
that cell

is this prescribed behavior for the Number editor/renderer, or am i
doing something wrong in the code?

thanks in advance for clearing this up for me,

Greg Goodman

however, this code behaves strangely on my system (wxPython 2.3.2.1 and
Python 2.1.1 under Linux 2.4.2). the last value entered in any cell in
column 0 is automatically entered when i click on any other empty cell
in column 0.

The debug version has an assert message that would probably have helped you,
("this cell doesn't have numeric value"). If you put zeros in the cells
then it should work. However I think empty cells should be treated as zero
so I'll do a fix for this.

···

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