validators

Various validator classes

Classes:

CharValidator(flag)

A Validator that only allows the type of characters selected to be entered.

FloatValidator(flag)

A Validator that only allows numbers and decimal points to be entered.

ValidatorBase()

Base class for Validators.

class CharValidator(flag)[source]

Bases: ValidatorBase

A Validator that only allows the type of characters selected to be entered.

The possible flags are:

  • int-only - only the numbers 0123456789 can be entered.

  • float-only - only numbers and decimal points can be entered.

Methods:

Clone()

Clones the CharValidator.

OnChar(event)

Event handler for text being entered in the control.

Validate(win)

Validate the control.

Clone()[source]

Clones the CharValidator.

OnChar(event)[source]

Event handler for text being entered in the control.

Parameters

event – The wxPython event.

Validate(win)[source]

Validate the control.

Parameters

win

Return type

bool

class FloatValidator(flag)[source]

Bases: CharValidator

A Validator that only allows numbers and decimal points to be entered. If a decimal point has already been entered, a second one cannot be entered. The argument flag is used to limit the number of decimal places that can be entered.

Methods:

OnChar(event)

Event handler for text being entered in the control.

OnChar(event)[source]

Event handler for text being entered in the control.

Parameters

event – The wxPython event.

class ValidatorBase[source]

Bases: Validator

Base class for Validators.

Methods:

Clone()

Clones the wx.Validator.

TransferFromWindow()

Transfer data from window to validator.

TransferToWindow()

Transfer data from validator to window.

reset_ctrl()

Resets the control’s background colour.

set_warning()

Set the control’s background colour to pink.

Clone()[source]

Clones the wx.Validator.

TransferFromWindow()[source]

Transfer data from window to validator.

The default implementation returns False, indicating that an error occurred. We simply return True, as we don’t do any data transfer.

Return type

bool

TransferToWindow()[source]

Transfer data from validator to window.

The default implementation returns False, indicating that an error occurred. We simply return True, as we don’t do any data transfer.

Return type

bool

reset_ctrl()[source]

Resets the control’s background colour.

Return type

bool

set_warning()[source]

Set the control’s background colour to pink.

Return type

bool