Book Image

Kivy - Interactive Applications and Games in Python

By : Roberto Ulloa
Book Image

Kivy - Interactive Applications and Games in Python

By: Roberto Ulloa

Overview of this book

Table of Contents (13 chapters)
Kivy – Interactive Applications and Games in Python Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Binding and unbinding events – sizing limbs and heads


In the previous two sections, we override basic events to perform actions we want. In this section, you will learn how to bind and unbind events dynamically. It was quite an easy job to add our Stickman because it is a Widget already, but what about the graphics, the circle, and the rectangle? We could create some widgets for them, just as we did with the Stickman, but let's attempt something braver before that. Instead of just clicking on the drawing space, let's drag the mouse on its border to decide the size of the circle or line:

Using mouse to set the size

Once we finish the dragging (and we are satisfied with the size), let's dynamically create DraggableWidget that will contain the shape, so we can also drag them over the DrawingSpace instance. The following class diagram will help us understand the whole inheritance structure of the toolbox.py file:

The diagram includes ToolButton and ToolsStickman, which were explained in the last...