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

Factory – replacing a vertex instruction


This final section of this chapter teaches a valuable trick to change the default properties of the vertex instructions. We want to change the width of all the lines on our interface. This includes the circles, lines, and stickmen. Of course, we could revisit all the classes that create the Line vertex instructions (remember that the circles are also Line instances, and the stickmen are composed of Line instances as well), and change the width property in all of them. Needless to say, that would be tedious.

Instead, we will replace the default Line class. Indeed, this is equivalent to what we just did in the previous section when we changed the label and button default properties. We have a problem in that we cannot create rules in the Kivy language to change the vertex instructions. But there is an equivalent way around this, using Python code in a new file called style.py:

346. # File name: style.py
347. from kivy.graphics import Line
348. from kivy...