Book Image

Kivy: Interactive Applications in Python

By : Roberto Ulloa
4 (1)
Book Image

Kivy: Interactive Applications in Python

4 (1)
By: Roberto Ulloa

Overview of this book

Mobiles and tablets have brought with them a dramatic change in the utility of applications. Compatibility has become essential, and this has increased the kind of interaction that users expect: gestures, multi-touches, animations, and magic pens. Kivy is an open source Python solution that covers these market needs with an easy-to-learn and rapid development approach. Kivy is growing fast and gaining attention as an alternative to the established developing platforms. Kivy: Interactive Applications in Python quickly introduces you to the Kivy development methodology. You will learn some examples of how to use many of the Kivy components, as well as understand how to integrate and combine them into big projects. This book serves as a reference guide and is organized in such a way that once finished, you will have already completed your first project. You will start by learning the Kivy Language for building User Interfaces (UI) and vector figures. We then proceed to the uses of Kivy events and properties to glue the UI with the application logic. You then go on to build an entire User Interface (UI) starting from a hand-made sketch. Furthermore, you will go on to understand how to use the canvas and drawing instructions to create different types of geometrical figures. Finally, you will be introduced to a big set of interactive and smooth features: transformations (scale, rotate, and translate), gestures, animations, scheduling tasks, and multi-touch elements. Kivy: Interactive Applications in Python expands your knowledge by introducing various components that improve the User Experience (UX). Towards the end of the book, you will be confident to utilize Kivy components and strategies to start any application or game you have in mind.
Table of Contents (13 chapters)
Kivy: Interactive Applications in Python
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Mobile devices have changed the way applications are. They have increased interaction types the user expects gestures, multi-touches, animations, and magic-pens. Moreover, compatibility has become a must-have if you want to avoid the barriers imposed by major Operative Systems. Kivy is an Open Source Python solution that covers these market needs with an easy to learn and rapid development approach. Kivy is growing fast and gaining attention as an alternative to the established developing platforms.

This book introduces you into the Kivy world, covering a large variety of important topics related to interactive application development. The components presented in this book were not only selected according to their usefulness for developing state-of-the- art applications, but also for serving as an example of broader Kivy functionalities. Following this approach, the book covers a big part of the Kivy library.

Instead of giving a detailed description of all the functions and properties, it provides you with examples to understand their use and how to integrate the two big projects that come with the book. The first one, the comic creator, exemplifies how to build a user interface, how to draw vector shapes in the screen, how to bind user interactions with pieces codes and other components related to improve the user experience. The second project, Invaders Revenge, is a very interactive game that introduces you to the use of animations, scheduling of tasks, keyboard events and multi-touch control.

Occasionally the book explains some technical but important Kivy concepts that are related to the order and strategies used to draw in the screen. These explanations give the readers some insights into the Kivy internals that will help them solve potential problems when they are developing their own projects. Even though they are not necessary for the comprehension of the main topics of this book, they will become important lessons when the readers are implementing their own applications.

The book keeps the readers attention by stating small problems and their solutions. The sections are short and straightforward, making the learning process constant. These short sections will also serve as a reference when they finish the book. However, serving as a reference doesn't prevent the text from achieving the main goal, which is teaching with bigger projects that connects the small topics. At the end of the book, the readers will feel comfortable to start their own project.

What this book covers

Chapter 1, GUI Basics Building an Interface ntroduces basic components and layouts of Kivy and how to integrate them through the Kivy Language

Chapter 2,Graphics The Canvas xplains the use of the canvas and how to draw vector figures on the screen

Chapter 3, Widget Events - Binding Actions eaches how to connect the interactions of the user through the interface with particular code inside the program

Chapter 4,Improving the User Experience introduces a collection of useful components to enrich the interaction of the user with the interface

Chapter 5, Invaders Revenge Multitouch ntroduces components and strategies to build highly interactive applications

What you need for this book

This book requires a running installation of Kivy with all its requirements. The installation instructions can be found at http://kivy.org/docs/gettingstarted/installation.html.

Who this book is for

The book aims at Python developers who want to create exciting and interesting UI/UX applications. They should be already familiarized with Python and a good understanding of some software engineering concepts, particularly inheritance, classes and instances. That said, the code is kept as simple as possible and it avoids the use of very specific Python nuances. No previous experience of Kivy is required though some knowledge of event handling, scheduling and user interface, in general, would boost your learning.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "Missile and Shot inherits from the same class called Ammo, which also inherits from Image. There is also the Boom class that will create the effect of explosion when any Ammo is triggered."

A block of code is set as follows:

 # File name: hello.py
 import kivy
 kivy.require('1.7.0')
 
 from kivy.app import App
 from kivy.uix.button import Label
 
 class HelloApp(App):
   def build(self):
     return Label(text='Hello World!')
 
 if __name__=="__main__":
   HelloApp().run()

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Consider App as an empty window as shown in the following screenshot (Hello World! output)".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.