> My data for a PyGridTableBase grid come out of a postgres database,
> and many fields are numeric(7,2) or smallint.
> The corresponding grid columns have the appropriate cell editors.
> After editing a numeric(7,2) cell, the cell shows the two decimal
> positions, OK. However, in de underlying data the value of the
> edited cell is now a string. Why is this ?
What exact cell editors are you using? Does your table class
implement the methods like Can(G|S)etValueAs and (G|S)etValueAsDouble?
I use the buit_in things like
GridCellFloatRenderer(precision=2)) and GridCellFloatEditor()
On a float-cell the next two give False:
CanGetValueAs(0,5,gridlib.GRID_VALUE_FLOAT)
CanSetValueAs(0,5,gridlib.GRID_VALUE_FLOAT)
And these two give True:
CanGetValueAs(0,5,gridlib.GRID_VALUE_STRING)
CanSetValueAs(0,5,gridlib.GRID_VALUE_STRING)
I have not implemented any of them myself. How can they help me ?
Tutorial-like help about these methods or about Grid in general is
hard to find,
so I started deciphering all demo's about the PyGridTableBase,
but that takes some time.
Eventually my purpose is to update the postgres database, and I prefer to let
wxpython help me as much as posible.
Well, your complaint was that the values were strings after having been edited and by implementing those methods you give the grid a way to give the values to your table as floating point values instead of as strings, which is what I assumed you wanted. The other option would be to convert the strings that the editors are sending to your table into floating point values yourself.
···
On 7/11/12 7:27 AM, Egbert Bouwman wrote:
After my question/remark:
My data for a PyGridTableBase grid come out of a postgres database,
and many fields are numeric(7,2) or smallint.
The corresponding grid columns have the appropriate cell editors.
After editing a numeric(7,2) cell, the cell shows the two decimal
positions, OK. However, in de underlying data the value of the
edited cell is now a string. Why is this ?
Robin Dunn <robin@alldunn.com> wrote:
What exact cell editors are you using? Does your table class
implement the methods like Can(G|S)etValueAs and (G|S)etValueAsDouble?
I use the buit_in things like
GridCellFloatRenderer(precision=2)) and GridCellFloatEditor()
On a float-cell the next two give False:
CanGetValueAs(0,5,gridlib.GRID_VALUE_FLOAT)
CanSetValueAs(0,5,gridlib.GRID_VALUE_FLOAT)
And these two give True:
CanGetValueAs(0,5,gridlib.GRID_VALUE_STRING)
CanSetValueAs(0,5,gridlib.GRID_VALUE_STRING)
I have not implemented any of them myself. How can they help me ?