This is the name of the widget we will use, which is a clickable text input. The second line is:
Button:
This defines the button. The third line is:
id: f_but
This gives the button an ID of f_but, which we will use to reference the button. The fourth line is:
TextInput:
This defines the text input. The fifth line is:
text: f_but.state
This is the definition of the text that is in the text input where we are referencing the state of the button. It says that if you do not click the button, the text in the text input is normal, and if you click the button, the text in the text input is shown.
There's more…
An ID is limited in scope to the rule it is declared in, so in the preceding code, f_but cannot be accessed outside the <MyWidget> rule; that is, if we have a second <MyWidget2>, we are not able to reference f_but in <MyWidget2>.
Also ID is a weakref module for the widget and not the widget itself. As a consequence, storing the ID is not sufficient to keep the widget from being garbage collected. To demonstrate:
If we do not use ID.__self__ or in this case label_widget.__self__ just label_widget, we are going to get an error: ReferenceError: weakly-referenced object no longer exists.
See also
If you want to get more details about widgets, see the recipes in Chapter 4, Widgets.