Defining widget events

Now, we will study the events that are called widget-defined events. These kinds of events are inherent to the widget. This recipe will illustrate it with probably the most common widget—the button. We will perform two events: one when the button is pressed and the other when the button state is changed.

Getting ready

In this recipe, it is necessary to clear the difference between the state of the button and press action. Because the states of the button are not pressed and no pressed, they actually are normal and down. The press action changes between both states of the button.

How to do it…

To accomplish the end goal, follow these steps:

  1. First in the KV file, declare an empty label using the following code:
    <MyW>: Label: id: ...

Get Kivy Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.