Book Image

Kivy Blueprints

Book Image

Kivy Blueprints

Overview of this book

Table of Contents (17 chapters)
Kivy Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
The Python Ecosystem
Index

Connecting the dots


Our app already has a clear screen function but still draws just circles. Let's change it so that we can draw lines instead.

To follow continuous touch events (click-and-drag), we'll need to add a new event listener, on_touch_move. Every time the callback is invoked, it receives the latest point where the event occurred.

If we only had a single line going at every moment (like typically done on a desktop, since there is only one mouse pointer anyway), we could save the line we're currently drawing in self.current_line. But since we're aiming at multitouch support from the very beginning, we'll take another approach and store every line being drawn in the corresponding touch variable itself.

This works because for every continuous touch from start to end, all callbacks receive the same touch object. There is also a touch.ud property of the type dict (where ud is short for user data), which is specifically tailored to keep touch-specific attributes between event handler invocations...