[wxPython] Field validations in WxPython

This is a follow-up to a previous question re field-by-field validation on a
form. Thanks to Robin for his reply. However, I still have some problems.

I need to choose the appropriate event to trigger the validation, and if it
fails, display an error message and set control back to the field for
re-entry.

At the moment, I am using the "got focus" event to trigger the validation
when one field is left and another field entered. I have created a
"manager" class, which maintains a list of all text controls on the panel,
and an attribute to keep track of the currently active control.

I am using the "print" statement to print messages to the console while the
app is running. I find this a very useful debugging technique. I print a
message to indicate when a control gets focus, and when a control loses
focus.

I am testing on Windows98 and on Linux. Neither of them behave in the way I
want, and to confuse matters, they do not behave the same as each other!
Below I try to document the sequence of events for each one, together with
the debugging output.

To keep this simple, I will use two text controls - Txt1 and Txt2, and will
assume that when Txt1 is entered, it fails its validation.

ยทยทยท

----------------------------------------------------------------------------
-------------------------------------------------

Windows -

Cursor flashing on Txt1
Txt1 got focus Correct

Txt1 got focus Incorrect

Data entered, tab pressed
Txt1 lost focus Correct

Txt1 lost focus Incorrect

Txt2 got focus Correct

Validation performed, focus set to Txt1
Txt2 lost focus Correct

Txt2 lost focus Incorrect

Txt1 got focus Correct

Txt1 got focus Incorrect

MessageDialogBox displayed
Txt1 lost focus Correct

Txt1 lost focus Incorrect

OK button clicked
Txt1 got focus Correct

Txt1 got focus Incorrect

Txt2 got focus Incorrect

MessageDialogBox displayed 2nd time (incorrect) Txt1
lost focus Correct

Txt1 lost focus Incorrect

OK button clicked
Txt2 got focus Incorrect

Txt2 got focus Incorrect

Txt1 got focus Corrrect

Txt1 got focus Incorrect

MessageDialogBox displayed 3rd time(incorrect) Txt2
lost focus Correct

Txt2 lost focus Incorrect

Txt1 lost focus Correct

Txt1 lost focus Incorrect

OK button clicked
Txt1 got focus Correct

Txt1 got focus Incorrect

Txt1 is highlighted, typing appears in Txt1
Correct

If Txt2 is mouse-clicked to instead of tabbed to, the MessageDialogBox
appears six times instead of three!

Previous attempts ended with typing appearing in Txt2, but this problem
seems to have gone away for now.

----------------------------------------------------------------------------
------------------------------------------------

Linux (identical program) -

Cursor flashing on Txt1
Txt1 got focus Correct

Data entered, tab pressed
Txt1 lost focus Correct

Txt2 got focus Correct

Validation performed, focus set to Txt1
Txt2 lost focus Correct

Txt1 got focus Correct

MessageDialogBox displayed
Txt1 lost focus Correct

Txt1 lost focus Incorrect

OK button clicked
Txt1 got focus Correct

Txt1 and Txt2 are both highlighted, typing appears in Txt1
Incorrect

If Txt2 is mouse-clicked to instead of tabbed to, typing appears in Txt2
Incorrect

----------------------------------------------------------------------------
------------------------------------------------

I will be very grateful if someone can help me with this. I will be happy to
post some code if this would help.

TIA

Hanna