[wxPython] Grid question: Validating data against type & range?

Hi,

Q: Is there an easy way to check the value already in a cell against the
   data types (and ranges) allowed?

BACKGROUND: We regularly process files with fixed-width (2600 bytes
long) records, with anywhere from 1 to 700 records. MOST of the data is
clean, however there are a few fields that are occasionally filled-in
wrong.

I've set up a grid with the cells for the fields that get edited
regularly, and I've limited the types and ranges of data using the
example GridCustTable.py from the demo. Then, I read the file,
and make it a list if lists (rows of columns) similar to the code
shown in the example.

It loads nicely, and as I had hoped it puts the values for the bad data
in, despite what CanSetValueAs() says.

Now, I want to go through the grid, and colorize only the data that
doesn't meet the type/range criteria specified in the dataTypes list.

(I could write my own checker, but it seems logical to assume there'd
be a way to take advantage of the existing limits.)

- --
Kevin Cole, RHCE, Linux Admin | E-mail: kjcole@gri.gallaudet.edu
Gallaudet Research Institute | WWW: http://gri.gallaudet.edu/~kjcole/
Hall Memorial Bldg S-419 | Voice: (202) 651-5135
Washington, D.C. 20002-3695 | FAX: (202) 651-5746

Sorry, in a bit of a rush this evening. Take a look at the wiki grid manual, in particular, look at the custom renderer code. Basically, create a custom renderer that checks the value for validity, displaying it with an alternate color (for instance red).

Hope that helps,
Mike

Kevin Cole wrote:

···

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Q: Is there an easy way to check the value already in a cell against the
   data types (and ranges) allowed?

BACKGROUND: We regularly process files with fixed-width (2600 bytes
long) records, with anywhere from 1 to 700 records. MOST of the data is
clean, however there are a few fields that are occasionally filled-in
wrong.

I've set up a grid with the cells for the fields that get edited
regularly, and I've limited the types and ranges of data using the
example GridCustTable.py from the demo. Then, I read the file,
and make it a list if lists (rows of columns) similar to the code
shown in the example.

It loads nicely, and as I had hoped it puts the values for the bad data
in, despite what CanSetValueAs() says.

Now, I want to go through the grid, and colorize only the data that
doesn't meet the type/range criteria specified in the dataTypes list.

(I could write my own checker, but it seems logical to assume there'd
be a way to take advantage of the existing limits.)

- --
Kevin Cole, RHCE, Linux Admin | E-mail: kjcole@gri.gallaudet.edu
Gallaudet Research Institute | WWW: http://gri.gallaudet.edu/~kjcole/
Hall Memorial Bldg S-419 | Voice: (202) 651-5135
Washington, D.C. 20002-3695 | FAX: (202) 651-5746

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8/XOwh8702ObzMscRAgumAJ9CWRRf7r+1WPlYS69g9X9O3oR3zwCdEnDl
l2Oy50/JJ3k6HPN7Ekl4yjo=
=Sm5L
-----END PGP SIGNATURE-----

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users

--
_______________________________________
   Mike C. Fletcher
   http://members.rogers.com/mcfletch/

Sorry, in a bit of a rush this evening. Take a look at the wiki grid
manual, in particular, look at the custom renderer code. Basically,
create a custom renderer that checks the value for validity, displaying
it with an alternate color (for instance red).

Hi,

Thanks for the respnse, but "checks the value for validity" is the
question not the answer. :wink: I meant, "Is there a simple call that
checks the validity?" I could invent a wheel, but it would probably
leak air. I want to see if the wheel's already there. I want something
like wxCheck(row,col) that is either true or false based on whether the
type (and range) of the value matches what I've put into the dataTypes
list.

If there isn't anything already, do I just do a GetTypeName(row, col)
and then compare it to what's in dataTypes[col]?

SMALL RANT (half humorous): I'm also seeing hints on this list (and
others) that "alpha", "beta" and "pre-release" have absolutely no
meaning any more. If I read the wiki doc right -- which is a stretch --
it seems to say that I'll need wxPyGridCellRender's Draw, but that in
order to get Draw to work right, I have to use a version of wxPython
whose version used to mean "use at your own risk, this could break
everything". Will the target ever stop moving for 15 minutes? Just long
enough to actually write an application that might actually be put into
a production environment? :wink: Sorry. I really DO like the toys I've
aquired. I guess I'm just a bit short on sleep.

I wrote:

···

On Wed, 5 Jun 2002, Mike C. Fletcher wrote:

> Hi,
>
> Q: Is there an easy way to check the value already in a cell against
> the data types (and ranges) allowed?
>
> BACKGROUND: We regularly process files with fixed-width (2600 bytes
> long) records, with anywhere from 1 to 700 records. MOST of the
> data is clean, however there are a few fields that are occasionally
> filled-in wrong.
>
> I've set up a grid with the cells for the fields that get edited
> regularly, and I've limited the types and ranges of data using the
> example GridCustTable.py from the demo. Then, I read the file, and
> make it a list if lists (rows of columns) similar to the code shown
> in the example.
>
> It loads nicely, and as I had hoped it puts the values for the bad
> data in, despite what CanSetValueAs() says.
>
> Now, I want to go through the grid, and colorize only the data that
> doesn't meet the type/range criteria specified in the dataTypes
> list.
>
> (I could write my own checker, but it seems logical to assume
> there'd be a way to take advantage of the existing limits.)

Sorry about the misunderstanding. To the best of my knowledge (assuming I now understand the question), the answer is "no, there's no API call to compare the stored value of (row,col) against a declared row or col datatype". I'd be surprised if the base table is doing anything to the value other than associating it with a custom renderer (float renderer, int renderer, bool renderer (and maybe editors)).

It's possible the underlying (hidden) wxGridTableBase storage is actually converting the data to the given data type (so might know about an out-of-type piece of data), but the names "SetColFormat*" etc. suggest they're just setting display formatting (i.e. renderer/editor) associations).

Re: the wxGrid and it's state of readiness

  I've used this control a lot lately (hence writing the wiki manual), and I would consider it (not wxPython as a whole) beta quality. There are lots of things still getting worked into usable shape, you can get some work done, but expect rough edges and constant upgrades until it stabalises. The new wxGrid implementation is still very new, and the wxPython wxGrid wrapper for the new implementation hasn't really been used enough to iron out all the kinks.

  As for creating a globally stable target release, sounds good. The problem is that wxPython is a _huge_ library produced by a tiny group of people (well, really just Robin AFAIK) that wraps other people's work (wxWindows) which isn't really targetted at making Robin's work easier and is in constant (non-uniform) flux with a tool written by yet other people (SWIG) who probably don't care _that_ much about the particular needs of wxPython.

  We could really use some automated (or even manual) quality-assurance operations and a suite of testing applications that exercise corner cases.

  We could probably use a few people to take care of release management, bug-triage, end-user-support, and documentation writing/maintenance.

  We could really use (to produce a "stable" branch) at least 1 more core developer working at back-porting of bug-fixes into a stable release tree. (Robin has said before that he just doesn't have the bandwidth to work on that + everything else he does).

  At the moment, however, there's basically just Robin working on the wxPython tree AFAIK, with the community of users trying to help out with the rest of the ops. The x.x version releases tend to be fairly stable, but obviously, they don't include the latest features appearing in the beta releases.

  I don't consider there to be an stable realease of the (new) wxPython wxGrid control yet (with the hope that 2.3.3 will include a first stable release somewhere in the back of my mind). I'm holding off deploying my calendaring application until 2.3.3 is available and I can test it. That's what I would suggest for anyone working with the new wxGrid control, but it's possible I'm over-cautious.

  Maybe some sort of warning should be on the wxGrid Manual that it's dealing with new-and-emerging technology whose alpha/beta/release status isn't necesarily related to the wxPython alpha/beta/release status. Maybe at a larger level we need a map/list declaring individual component's readiness level included in the demo or documentation. I don't know.

Okay, must get off to real work now.
Smile everybody, life is good.
Mike

Kevin Cole wrote:

···

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 5 Jun 2002, Mike C. Fletcher wrote:

Sorry, in a bit of a rush this evening. Take a look at the wiki grid manual, in particular, look at the custom renderer code. Basically, create a custom renderer that checks the value for validity, displaying it with an alternate color (for instance red).

Hi,

Thanks for the respnse, but "checks the value for validity" is the
question not the answer. :wink: I meant, "Is there a simple call that
checks the validity?" I could invent a wheel, but it would probably
leak air. I want to see if the wheel's already there. I want something
like wxCheck(row,col) that is either true or false based on whether the
type (and range) of the value matches what I've put into the dataTypes
list.

If there isn't anything already, do I just do a GetTypeName(row, col)
and then compare it to what's in dataTypes[col]?

SMALL RANT (half humorous): I'm also seeing hints on this list (and
others) that "alpha", "beta" and "pre-release" have absolutely no
meaning any more. If I read the wiki doc right -- which is a stretch --
it seems to say that I'll need wxPyGridCellRender's Draw, but that in
order to get Draw to work right, I have to use a version of wxPython
whose version used to mean "use at your own risk, this could break
everything". Will the target ever stop moving for 15 minutes? Just long
enough to actually write an application that might actually be put into
a production environment? :wink: Sorry. I really DO like the toys I've
aquired. I guess I'm just a bit short on sleep.

I wrote:

Hi,

Q: Is there an easy way to check the value already in a cell against
  the data types (and ranges) allowed?

BACKGROUND: We regularly process files with fixed-width (2600 bytes
long) records, with anywhere from 1 to 700 records. MOST of the
data is clean, however there are a few fields that are occasionally
filled-in wrong.

I've set up a grid with the cells for the fields that get edited
regularly, and I've limited the types and ranges of data using the
example GridCustTable.py from the demo. Then, I read the file, and
make it a list if lists (rows of columns) similar to the code shown
in the example.

It loads nicely, and as I had hoped it puts the values for the bad
data in, despite what CanSetValueAs() says.

Now, I want to go through the grid, and colorize only the data that
doesn't meet the type/range criteria specified in the dataTypes
list.

(I could write my own checker, but it seems logical to assume
there'd be a way to take advantage of the existing limits.)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8/1KJh8702ObzMscRAgwAAJ9EsyccPSfej4r+KaJdyEJAJ0opAACg3plw
zGXw/AlOFe3qULYTzMO/D04=
=LJ9e
-----END PGP SIGNATURE-----

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users

--
_______________________________________
   Mike C. Fletcher
   http://members.rogers.com/mcfletch/

Ahhh, that gives me something to go on. Thanks. And I realize the
problems that Robin and others face in trying to make it all hang
together. Given that, I like the idea of getting a sense of which parts
of the bleeding edge version are unstable (maybe on the wiki), if people
are going to keep recommending the bleeding edge to solve problems.
(The other possibility is to leave unstable stuff out of versions that
are declared stable.)

Sorry about the misunderstanding. To the best of my knowledge (assuming
I now understand the question), the answer is "no, there's no API call
to compare the stored value of (row,col) against a declared row or col
datatype". I'd be surprised if the base table is doing anything to the
value other than associating it with a custom renderer (float renderer,
int renderer, bool renderer (and maybe editors)).

I've used this control a lot lately (hence writing the wiki manual),
and I would consider it (not wxPython as a whole) beta quality.
There are lots of things still getting worked into usable shape, you
can get some work done, but expect rough edges and constant upgrades
until it stabalises. The new wxGrid implementation is still very new,
and the wxPython wxGrid wrapper for the new implementation hasn't
really been used enough to iron out all the kinks.

         [ --- 8< --- snip --- 8< --- snip --- 8< --- ]

···

On Thu, 6 Jun 2002, Mike C. Fletcher wrote:

Maybe some sort of warning should be on the wxGrid Manual that it's
dealing with new-and-emerging technology whose alpha/beta/release
status isn't necesarily related to the wxPython alpha/beta/release
status. Maybe at a larger level we need a map/list declaring
individual component's readiness level included in the demo or
documentation. I don't know.