hscommon.gui.text_field¶
| TextField() | Cross-toolkit text field. |
| TextFieldView | Expected interface for TextField‘s view. |
- class hscommon.gui.text_field.TextField¶
Cross-toolkit text field.
Represents a UI element allowing the user to input a text value. Its main attribute is text which acts as the store of the said value.
When our model value isn’t a string, we have a built-in parsing/formatting mechanism allowing us to directly retrieve/set our non-string value through value.
Subclasses GUIObject. Expected view: TextFieldView.
- _format(value)¶
(Virtual) Formats value to put into text.
Returns the formatted version of value. Called whenever value changes.
- _parse(text)¶
(Virtual) Parses text to put into value.
Returns the parsed version of text. Called whenever text changes.
- _update(newvalue)¶
(Virtual) Called whenever we have a new value.
Whenever our text/value store changes to a new value (different from the old one), this method is called. By default, it does nothing but you can override it if you want.
- class hscommon.gui.text_field.TextFieldView¶
Expected interface for TextField‘s view.
Not actually used in the code. For documentation purposes only.
Our view is expected to sync with TextField.text “both ways”, that is, update the model’s text when the user types something, but also update the text field when refresh() is called.
- refresh()¶
Refreshes the contents of the input widget.
Ensures that the contents of the input widget is actually TextField.text.