Book Image

Kivy Cookbook

By : Hugo Solis
Book Image

Kivy Cookbook

By: Hugo Solis

Overview of this book

Table of Contents (16 chapters)
Kivy Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using context instructions


This recipe brings colors to our apps. As we said, the context instructions are those that do not draw but give context to the canvas. The recipe will give color to some geometric shapes.

Getting ready

The last recipe is related to this recipe. So, it should be useful to compare them because you will better understand the difference between the context and drawing instructions with practice. Also, we will use different color models, such as RGB.

How to do it…

Here, we are going to use a simple Python file in our app and concentrate on the KV file, which will have context and drawing instructions to generate the graphics in the app. To complete the recipe, follow these steps:

  1. In the KV file, define the rule for the root widget.

  2. Define the canvas property for the root widget.

  3. Add the drawing instructions for an ellipse.

  4. Add the context instructions for a color in RGB.

  5. Add the drawing instructions for a rectangle.

  6. Add the drawing instructions for a triangle.

  7. Add the context...