navigate.view.custom_widgets.validation.ValidatedEntry
- class navigate.view.custom_widgets.validation.ValidatedEntry(*args, precision=0, required=False, min_var=None, max_var=None, focus_update_var=None, min='-Infinity', max='Infinity', **kwargs)
Bases:
ValidatedMixin,EntryA validated entry widget
Entry class that requires Entry Can optionally pass in a precision, min value, max value and a boolean for whether the entry requires a value. The min_var, max_var, and focus_update_var are the same as a spinbox
- __init__(*args, precision=0, required=False, min_var=None, max_var=None, focus_update_var=None, min='-Infinity', max='Infinity', **kwargs)
Initialise the entry widget
- Parameters:
parent (tk.Widget) – The parent widget
precision (int, optional) – The precision of the entry, by default 0
min_var (tk.Variable, optional) – The minimum value of the entry, by default None
max_var (tk.Variable, optional) – The maximum value of the entry, by default None
required (bool, optional) – Whether the entry requires a value, by default False
focus_update_var (tk.Variable, optional) – The variable to update when focus is lost, by default None
min (str, optional) – The minimum value of the entry, by default “-Infinity”
max (str, optional) – The maximum value of the entry, by default “Infinity”
**kwargs – Keyword arguments to pass to the entry
Methods
__init__(*args[, precision, required, ...])Initialise the entry widget
add_history(event)Add the current value to the history of the widget.
redo(event)Redo the last change that was undone.
set(value)Set the value of the entry to the given value.
set_precision(prec)Set the precision of the entry in decimal places.
Trigger the focusout validation of the widget
undo(event)Undo the last change to the widget.
Attributes
- add_history(event)
Add the current value to the history of the widget.
- Parameters:
event (tk.Event) – The event that triggered the history addition
- redo(event)
Redo the last change that was undone.
- Parameters:
event (tk.Event) – The event that triggered the redo
- set(value)
Set the value of the entry to the given value.
- Parameters:
value (str) – The value to set the entry to
Examples
>>> widget = ValidatedEntry(parent) >>> widget.set('1')
- set_precision(prec)
Set the precision of the entry in decimal places.
Given a precision it will update the spinboxes ability to handle more or less precision for validation. This is separate from the increment value.
- Parameters:
prec (int) – The precision to set the entry to
Examples
>>> widget = ValidatedEntry(parent) >>> widget.set_precision(1)
- trigger_focusout_validation()
Trigger the focusout validation of the widget
- undo(event)
Undo the last change to the widget.
- Parameters:
event (tk.Event) – The event that triggered the undo
- error
The variable to store the error message in
- Type:
tk.StringVar
- max
The maximum value of the entry
- Type:
str
- min
The minimum value of the entry
- Type:
str
- precision
The precision of the entry
- Type:
int
- redo_history
The redo history of the widget
- Type:
list
- required
Whether the entry requires a value
- Type:
bool
- resolution
The resolution of the entry
- Type:
Decimal
- undo_history
The undo history of the widget
- Type:
list
- variable
The variable to store the value of the entry in
- Type:
tk.StringVar