hscommon.gui.text_field¶
Cross-toolkit text field. |
|
Expected interface for |
-
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
textwhich 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
valueto put intotext.Returns the formatted version of
value. Called whenevervaluechanges.
-
_parse(text)¶ (Virtual) Parses
textto put intovalue.Returns the parsed version of
text. Called whenevertextchanges.
-
_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.
-
_view_updated()¶ (Virtual) Called after
viewhas been set.Doing nothing by default, this method is called after
viewhas been set (it isn’t called when it’s unset, however). Use this for initialization code that requires a view (which is often the whole of the initialization code).
-
-
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 whenrefresh()is called.-
refresh()¶ Refreshes the contents of the input widget.
Ensures that the contents of the input widget is actually
TextField.text.
-