Binding events in the Kivy language
In this section you will learn to bind events in the Kivy language. Potentially, we could have done this since the very beginning of the chapter when we started working with DraggableWidget
but there is a difference. The difference is that if we use the Kivy language we can easily add the event to a specific instance and not to all the instances of the same class. For example, when we add the touch basic events to the
DraggableWidget
, all the instances created from it receive the implementation. In this sense, it resembles to externally binding an instance to its callback with the bind
method. All that said, we can still make this binding of the class definition, if we added the code directly to the rule (<DraggableWidget>:
) that defines the class. In any case, we are going to concentrate on new events specific for Button
and ToggleButton
.
The following is the code for generaloption.kv
:
190. # File name: generaloptions.kv 191. #:import generaloptions...