Config
elva.widgets.config
Configuration panel widgets for Textual
apps.
Classes:
-
ConfigPanel
–Container for
ConfigView
widgets. -
ConfigView
–Wrapper Container around user-facing input widgets.
-
ConfigInput
–Input widget being able to let paste event messages bubble.
-
RadioSelect
–List of options with radio buttons.
-
RadioSelectView
–Configuration view wrapper around a
RadioSelect
widget. -
TextInputView
–Configuration view wrapper around a
ConfigInput
widget for generic text input. -
URLInputView
–Configuration view wrapper around a
ConfigInput
widget for URLs. -
PathInputView
–Configuration view wrapper around a
ConfigInput
widget for paths. -
SwitchView
–Configuration view wrapper around a
Switch
widget. -
QRCode
–Collapsible QR code displaying widget.
-
QRCodeView
–Configuration view wrapper around a
QRCode
widget. -
WebsocketsURLValidator
–Websocket URL validator.
-
PathSuggester
–Suggester for paths.
ConfigPanel(config, applied=False, label=None)
Bases: Container
Container for ConfigView
widgets.
Parameters:
-
config
(dict
) –configuration parameter mapping to apply to write to the panel.
-
applied
(bool
, default:False
) –if
False
, treat all config view values as changed. -
label
(str
, default:None
) –label string for the panel itself to be displayed at the top.
Classes:
-
Applied
–Message object holding configuration change information.
Methods:
-
compose
–Hook arranging config view widgets.
-
apply
–Store the current value also as last value.
-
reset
–Reset the current value to the last value.
-
post_applied_config
–Send an
Applied
message. -
on_button_pressed
–Hook called on a pressed button.
-
decode_content
–Try to decode content according to TOML syntax.
-
on_paste
–Hook called on a paste event.
Attributes:
-
state
–Current configuration parameters.
-
last
–Previous configuration parameters.
-
changed
–Changed configuration parameters.
Source code in src/elva/widgets/config.py
state
property
Current configuration parameters.
last
property
Previous configuration parameters.
changed
property
Changed configuration parameters.
Applied(last, config, changed)
Bases: Message
Message object holding configuration change information.
Parameters:
-
last
(dict
) –previous configuration mapping.
-
config
(dict
) –current configuration mapping.
-
changed
(dict
) –mapping of changed configuration parameters.
Attributes:
-
last
(dict
) –Previous configuration mapping.
-
config
(dict
) –Current configuration mapping.
-
changed
(dict
) –Mapping of changed configuration parameters.
Source code in src/elva/widgets/config.py
last = last
instance-attribute
Previous configuration mapping.
config = config
instance-attribute
Current configuration mapping.
changed = changed
instance-attribute
Mapping of changed configuration parameters.
compose()
Hook arranging config view widgets.
Source code in src/elva/widgets/config.py
apply()
reset()
post_applied_config()
on_button_pressed(message)
Hook called on a pressed button.
Either posts an Applied
message or resets the config views.
Parameters:
-
message
(Message
) –message object from the pressed button event.
Source code in src/elva/widgets/config.py
decode_content(content)
Try to decode content according to TOML syntax.
Parameters:
-
content
(str
) –TOML data string to be parsed.
Returns:
-
dict
–parsed configuration mapping.
Source code in src/elva/widgets/config.py
on_paste(message)
Hook called on a paste event.
The pasted content is assumed to be TOML syntax and tried to be parsed. On success, the config views get updated if the corresponding keys have been pasted.
Parameters:
-
message
(Message
) –message object from the paste event.
Source code in src/elva/widgets/config.py
ConfigView(widget)
Bases: Container
Wrapper Container around user-facing input widgets.
It allows consistent styling via TCSS classes.
Parameters:
-
widget
(Widget
) –internal user-facing input widget.
Classes:
Methods:
-
compose
–Hook arranging child widgets.
-
on_mount
–Hook applying the configuration parameters when mounted.
-
apply
–Set the last value to the current value.
-
reset
–Set the current value to the last value.
-
toggle_button_visibility
–Manage the
invisible
TCSS class onButton
widgets. -
on_enter
–Hook called on pressed
Enter
key. -
on_leave
–Hook called on the mouse pointer leaving the widget's bounds.
-
watch_hover
–Hook called on hover changed.
-
on_descendant_focus
–Hook called on child widgets gaining focus.
-
on_descendant_blur
–Hook called on child widgets loosing focus.
-
watch_focus_within
–Hook called on focus changed in child widgets.
Attributes:
-
last
(Any
) –Previous value of the configuration parameter.
-
hover
(bool
) –Flag whether the mouse pointer is hovering over this container.
-
focus_within
(bool
) –Flag whether the child widgets have focus.
-
changed
(bool
) –Flag whether the configuration value has changed.
-
name
(str
) –Key of the configuration parameter.
-
value
(Any
) –Value of the configuration parameter.
Source code in src/elva/widgets/config.py
last
instance-attribute
Previous value of the configuration parameter.
hover = reactive(False)
class-attribute
instance-attribute
Flag whether the mouse pointer is hovering over this container.
focus_within = reactive(False)
class-attribute
instance-attribute
Flag whether the child widgets have focus.
changed
property
Flag whether the configuration value has changed.
name
property
Key of the configuration parameter.
value
property
writable
Value of the configuration parameter.
Changed(name, value)
Bases: Message
Message object posted on change events.
Parameters:
-
name
(str
) –key of the configuration parameter.
-
value
(Any
) –value of the configuration parameter.
Attributes:
-
name
(str
) –Key of the configuration parameter.
-
value
(Any
) –Value of the configuration parameter.
Source code in src/elva/widgets/config.py
name = name
instance-attribute
Key of the configuration parameter.
value = value
instance-attribute
Value of the configuration parameter.
Saved(name, value)
Bases: Message
Message object posted on save events.
Parameters:
-
name
(str
) –key of the configuration parameter.
-
value
(Any
) –value of the configuration parameter.
Attributes:
-
name
(str
) –Key of the configuration parameter.
-
value
(Any
) –Value of the configuration parameter.
Source code in src/elva/widgets/config.py
name = name
instance-attribute
Key of the configuration parameter.
value = value
instance-attribute
Value of the configuration parameter.
compose()
on_mount()
apply()
reset()
toggle_button_visibility(state)
Manage the invisible
TCSS class on Button
widgets.
Parameters:
-
state
(bool
) –if
True
, remove theinvisible
TCSS class from button widgets, else add it to them.
Source code in src/elva/widgets/config.py
on_enter(message)
on_leave(message)
Hook called on the mouse pointer leaving the widget's bounds.
This sets the hover
flag to False
only if the mouse has really left the own boundaries and the inner input widget is not focused.
Parameters:
-
message
(Message
) –message object posted on the pressed
Enter
key event.
Source code in src/elva/widgets/config.py
watch_hover(hover)
Hook called on hover changed.
This toggles the button visibility accordingly.
Parameters:
Source code in src/elva/widgets/config.py
on_descendant_focus(message)
Hook called on child widgets gaining focus.
This sets the focus_within
flag to True
.
Parameters:
-
message
(Message
) –message object posted on focus gain event in child widgets.
Source code in src/elva/widgets/config.py
on_descendant_blur(message)
Hook called on child widgets loosing focus.
This sets the focus_within
flag to False
.
Parameters:
-
message
(Message
) –message object posted on focus loss event in child widgets.
Source code in src/elva/widgets/config.py
watch_focus_within(focus)
Hook called on focus changed in child widgets.
This toggles the button visibility accordingly.
Parameters:
-
focus
(bool
) –current value of
focus_within
.
Source code in src/elva/widgets/config.py
ConfigInput
Bases: Input
Input widget being able to let paste event messages bubble.
_on_paste(message)
Hook called on a paste event.
This allows the message
object to bubble up if the pasted content is valid TOML syntax, but does nothing else with it.
Parameters:
-
message
(Message
) –message object posted in a paste event.
Source code in src/elva/widgets/config.py
RadioSelect(options, *args, value=None, **kwargs)
Bases: Container
List of options with radio buttons.
Parameters:
-
options
(list[tuple[str, Any]]
) –name-value-tuples holding values alongside their displayable names.
-
value
(None | Any
, default:None
) –current value to select upfront.
-
args
(tuple
, default:()
) –positional arguments passed to the
Container
class. -
kwargs
(dict
, default:{}
) –keyword arguments passed to the
Container
class.
Methods:
-
from_values
–Create a new instance from a list of options.
-
compose
–Hook arranging child widgets.
-
on_click
–Hook called on mouse click event.
Attributes:
-
names
(list[str]
) –List of names representing the values.
-
values
(list[Any]
) –List of values at choice.
-
buttons
(dict[str, RadioButton]
) –Mapping of
RadioButton
instances to the values' names. -
options
(dict[str, Any]
) –Mapping of values to their corresponding name.
-
radio_set
(RadioSet
) –Instance of the inner
RadioSet
widget. -
value
(Any
) –Value of currently active, i.e. selected, radio button.
Source code in src/elva/widgets/config.py
names
instance-attribute
List of names representing the values.
values
instance-attribute
List of values at choice.
buttons = dict((n, RadioButton(n, value=v == value, name=n)) for (n, v) in options)
instance-attribute
Mapping of RadioButton
instances to the values' names.
options = dict(options)
instance-attribute
Mapping of values to their corresponding name.
radio_set = RadioSet()
instance-attribute
Instance of the inner RadioSet
widget.
value
property
writable
Value of currently active, i.e. selected, radio button.
from_values(options, *args, value=None, **kwargs)
classmethod
Create a new instance from a list of options.
Parameters:
-
options
(list[Any]
) –list of values at choice with their string representation as displayed names.
-
value
(None | Any
, default:None
) –current value to select upfront.
-
args
(tuple
, default:()
) –positional arguments passed to the
Container
class. -
kwargs
(dict
, default:{}
) –keyword arguments passed to the
Container
class.
Source code in src/elva/widgets/config.py
compose()
on_click(message)
Hook called on mouse click event.
This sets the focus to the currently active radio button.
Parameters:
-
message
(Message
) –message object posted in a mouse click event.
Source code in src/elva/widgets/config.py
RadioSelectView(*args, **kwargs)
Bases: ConfigView
Configuration view wrapper around a RadioSelect
widget.
Parameters:
-
args
(tuple
, default:()
) –positional arguments passed to
RadioSelect
. -
kwargs
(dict
, default:{}
) –keyword arguments passed to
RadioSelect
.
Methods:
-
compose
–Hook arranging child widgets.
-
on_button_pressed
–Hook called on a button pressed event from the child widgets.
-
on_click
–Hook called on a mouse click event.
-
on_radio_set_changed
–Hook called when the radio set changes.
Source code in src/elva/widgets/config.py
compose()
on_button_pressed(message)
Hook called on a button pressed event from the child widgets.
This posts then a Saved
message.
Parameters:
-
message
(Message
) –message object posted on a button pressed event.
Source code in src/elva/widgets/config.py
on_click(message)
Hook called on a mouse click event.
This sets the focus to the inner radio set widget.
Parameters:
-
message
(Message
) –message object posted on a mouse click event.
Source code in src/elva/widgets/config.py
on_radio_set_changed(message)
Hook called when the radio set changes.
This posts then a Changed
message itself.
Parameters:
-
message
(Message
) –message object posted on a radio set changed event.
Source code in src/elva/widgets/config.py
TextInputView(*args, **kwargs)
Bases: ConfigView
Configuration view wrapper around a ConfigInput
widget for generic text input.
Parameters:
-
args
(tuple
, default:()
) –positional arguments passed to
ConfigInput
. -
kwargs
(dict
, default:{}
) –keyword arguments passed to
ConfigInput
.
Methods:
-
compose
–Hook arranging child widgets.
-
on_button_pressed
–Hook called on a button pressed event from the child widgets.
-
on_input_changed
–Hook called on an input change event.
Source code in src/elva/widgets/config.py
compose()
Hook arranging child widgets.
Source code in src/elva/widgets/config.py
on_button_pressed(message)
Hook called on a button pressed event from the child widgets.
This either copies the current value to clipboard or posts a Changed
message.
Parameters:
-
message
(Message
) –message object posted on a button pressed event.
Source code in src/elva/widgets/config.py
URLInputView(*args, **kwargs)
Bases: TextInputView
Configuration view wrapper around a ConfigInput
widget for URLs.
Parameters:
-
args
(tuple
, default:()
) –positional arguments passed to
ConfigInput
. -
kwargs
(dict
, default:{}
) –keyword arguments passed to
ConfigInput
.
Methods:
-
on_input_changed
–Hook called on an input change event.
Attributes:
-
value
–Value of the input field if being a valid URL.
Source code in src/elva/widgets/config.py
value
property
writable
Value of the input field if being a valid URL.
on_input_changed(message)
Hook called on an input change event.
This posts then a Changed
message if no validation result is present, i.e. no Validator
has been passed to the constructor, or the validation succeeded.
Additionally, the TCSS class invalid
is added or removed to the input widget depending on the validation result.
Parameters:
-
message
(Message
) –message object posted on an input change event.
Source code in src/elva/widgets/config.py
PathInputView(value, *args, **kwargs)
Bases: TextInputView
Configuration view wrapper around a ConfigInput
widget for paths.
Parameters:
-
value
(Any
) –currently set value in the input field.
-
args
(tuple
, default:()
) –positional arguments passed to
ConfigInput
. -
kwargs
(dict
, default:{}
) –keyword arguments passed to
ConfigInput
.
Attributes:
-
value
–Path object of the current value in the input field.
Source code in src/elva/widgets/config.py
value
property
writable
Path object of the current value in the input field.
SwitchView(*args, **kwargs)
Bases: ConfigView
Configuration view wrapper around a Switch
widget.
Parameters:
-
args
(tuple
, default:()
) –positional arguments passed to
Switch
. -
kwargs
(dict
, default:{}
) –keyword arguments passed to
Switch
.
Methods:
-
compose
–Hook arranging child widgets.
-
on_button_pressed
–Hook called on a button pressed event from the child widgets.
Source code in src/elva/widgets/config.py
compose()
on_button_pressed(message)
Hook called on a button pressed event from the child widgets.
This posts then a Saved
message.
Parameters:
-
message
(Message
) –message object posted on a button pressed event.
Source code in src/elva/widgets/config.py
QRCode(content, *args, collapsed=True, **kwargs)
Bases: Widget
Collapsible QR code displaying widget.
Parameters:
-
content
(str
) –the content to encode in the QR code.
-
collapsed
(bool
, default:True
) –flag whether the view is collapsed on mount.
-
args
(tuple
, default:()
) –positional arguments passed to the
Widget
class. -
kwargs
(dict
, default:{}
) –keyword arguments passed to the
Widget
class.
Methods:
-
compose
–Hook arrange the child widgets.
-
update_qrcode
–Update the displayed QR code.
-
watch_value
–Hook called on changed value.
Attributes:
-
qr
(QRCode
) –Instance of the QR code encoding object.
-
code
(Static
) –Widget instance holding the string representation of the QR code.
-
value
–QR code encoded data.
Source code in src/elva/widgets/config.py
qr = qrcode.QRCode(version=self.version, error_correction=qrcode.constants.ERROR_CORRECT_L, border=0)
instance-attribute
Instance of the QR code encoding object.
code = Static()
instance-attribute
Widget instance holding the string representation of the QR code.
value = content
class-attribute
instance-attribute
QR code encoded data.
compose()
update_qrcode()
Update the displayed QR code.
Source code in src/elva/widgets/config.py
watch_value()
QRCodeView(*args, **kwargs)
Bases: ConfigView
Configuration view wrapper around a QRCode
widget.
Parameters:
-
args
(tuple
, default:()
) –positional arguments passed to
QRCode
. -
kwargs
(dict
, default:{}
) –keyword arguments passed to
QRCode
.
Methods:
-
compose
–Hook arranging child widgets.
-
on_button_pressed
–Hook called on a button pressed event from the child widgets.
-
on_click
–Hook called on a mouse click event.
Source code in src/elva/widgets/config.py
compose()
on_button_pressed(message)
Hook called on a button pressed event from the child widgets.
This copies the current QR encoded value to clipboard.
Parameters:
-
message
(Message
) –message object posted on a button pressed event.
Source code in src/elva/widgets/config.py
on_click(message)
Hook called on a mouse click event.
This toggles the collapsed state.
Parameters:
-
message
(Message
) –message object posted on a mouse click event.
Source code in src/elva/widgets/config.py
WebsocketsURLValidator
Bases: Validator
Websocket URL validator.
This class is designed for use in the URLInputView
.
Methods:
-
validate
–Hook called when validation is requested.
validate(value)
Hook called when validation is requested.
Parameters:
-
value
(str
) –current input field value to be validated.
Returns:
-
ValidationResult
–a result object holding information about the validation outcome.
Source code in src/elva/widgets/config.py
PathSuggester
Bases: Suggester
Suggester for paths.
This class is designed for use in the PathInputView
widget.
Methods:
-
get_suggestion
–Hook called when a suggestion is requested.
get_suggestion(value)
async
Hook called when a suggestion is requested.
Parameters:
-
value
(str
) –current input widget value on which to base suggestions on.
Returns:
-
str
–suggested extended or completed path.