Creating custom events

Another possibility with events is that we can create and customize our own events. There are many situations where we could need a custom event; for example, when we create our own widget. This recipe will create a new event that will fire an action when the label of the button is changed.

Getting ready

Now we need a more complex recipe, and it is useful for the reader to review the recipes first before getting into the content of custom events in Kivy. We will also use the Kv language to design the widgets, so we assume that the reader is familiar with the Kv language or has gone through the first chapter.

How to do it…

Use the following steps to achieve the end goal:

  1. First, in the KV file, declare an empty label and a button ...

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.