Input Value Checking and Transfer

wxPython provides a system of "Validators" and certain controls which are aware of Validators. When available, these controls allow your system to use an approach similar to a DocumentViewArchitecture, where data is acquired and updated automatically from data objects by the UI elements.

Using Basic Validators

Using validators with "non validator" controls

Recursive validation (automatically validating child windows)

Limitations and coverage

Example

(Re-)writing dialog close/update methods to handle mixed Validator/non-validator controls

        def Validate( self, event ):
                '''Process an event for the okay button...'''
                # do validation for normal "Validator" controls
                if not wxWindow.Validate( self ):
                        return false
                # now walk through the other controls (
                for editor in self.controls:
                        if hasattr( editor, 'Validate') and not editor.Validate( self ):
                                return false
        def TransferDataFromWindow( self, ):
                if not wxWindow.TransferDataFromWindow( self ):
                        return false
                for editor in self.controls:
                        if hasattr( editor, 'TransferDataFromWindow'):
                                if not editor.TransferDataFromWindow():
                                        return false
        def TransferDataToWindow( self, ):
                if not wxWindow.TransferDataToWindow( self ):
                        return false
                for editor in self.controls:
                        if hasattr( editor, 'TransferDataToWindow'):
                                if not editor.TransferDataToWindow():
                                        return false

Display

xxx

InputValueCheckingAndTransfer (last edited 2008-03-11 10:50:23 by localhost)

NOTE: To edit pages in this wiki you must be a member of the TrustedEditorsGroup.