rgonzalez72/pytrainer — comment on commit 4234291653c4447c5cae56a45c1844f93798eb37
File:  line 0
By rgonzalez72:

Hi Nathan,

Ive upload a few changes I been working in during the morning (please disregard the old FieldValidator class that is still there).
I haven't look at the widget thing yet.

________________________________
From: Nathan Jones
To: rgonzalez72
Sent: Wednesday, 1 February 2012, 13:06
Subject: Re: [pytrainer] Working on issue 81 (4234291)

Yes, a class hierachy is the OO alternative to a type code.

For each field that needs to be validated you can just instantiate the appropriate type of validator. The validator can probably be made capable of generating sensible localised error messages.

My thoughts on a custom widget were to create a new abstract subclass of gkt.Widget which wraps another widget and provides validation state and validation events. Then there will be very minimal wiring together for the UI - there just needs to be the same validation state change listener added to each widget which will add or remove an error message from the UI. As you point out though, either there will need to be multiple error messages displayed at a time or, while errors still exist, previous error messages need to be restored after errors are resolved so this approach requires a bit more thought. Maybe the validation state change handler needs to iterate over all known inputs and revalidate them when one of the inputs validation state returns to "valid". The Eclipse IDE presents input validation messages in this way (one message per screen, updated as you type, relevant to the earliest invalid field on the screen) so it could be worthwhile looking
at the source code to
see what pattern is used there.

Whether we use custom widgets or not though there will still need to be the string input validation type hierarchy so I suggest going ahead with that and seeing how it looks.

---
Reply to this email directly or view it on GitHub:
https://github.com/rgonzalez72/pytrainer/commit/4234291653c4447c5cae56a45c1844f93798eb37#commitcomment-922247