Populating a grid

I did my first steps with wxGrid. I learned that one way to populate a Grid
is:

maedels is an array of Strings

grid.CreateGrid(len(maedels),len(maedels[0]))

for row in range(len(maedels)-1):
    for col in range(len(maedels[0])-1):
        print row,col,maedels[row][col]
        grid.SetCellValue(row,col,maedels[row][col])

That works perfect --- but does not look very nice. Is there a) faster b)
more elegant way to populate and size a wxGrid when an Array of Strings is
allready present?

Harald Massa wrote:

I did my first steps with wxGrid. I learned that one way to populate a Grid
is:

maedels is an array of Strings

grid.CreateGrid(len(maedels),len(maedels[0]))

for row in range(len(maedels)-1):
    for col in range(len(maedels[0])-1):
        print row,col,maedels[row][col]
        grid.SetCellValue(row,col,maedels[row][col])

That works perfect --- but does not look very nice. Is there a) faster b)
more elegant way to populate and size a wxGrid when an Array of Strings is
allready present?

You could derive a class from wxPyGridTableBase that provides the data in your array on an as needed basis. See the demo for a couple examples.

···

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