Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Kivy ??? Interactive Applications and Games in Python second edition

You're reading from   Kivy ??? Interactive Applications and Games in Python second edition Create responsive cross-platform UI/UX applications and games in Python using the open source Kivy library

Arrow left icon
Product type Paperback
Published in Jun 2015
Publisher
ISBN-13 9781785286926
Length 206 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Roberto Ulloa Roberto Ulloa
Author Profile Icon Roberto Ulloa
Roberto Ulloa
Arrow right icon
View More author details
Toc

Table of Contents (8) Chapters Close

Preface 1. GUI Basics – Building an Interface FREE CHAPTER 2. Graphics – the Canvas 3. Widget Events – Binding Actions 4. Improving the User Experience 5. Invaders Revenge – an Interactive Multi-touch Game 6. Kivy Player – a TED Video Streamer Index

Chapter 1. GUI Basics – Building an Interface

Kivy is a free, open source Python library that allows for quick and easy development of highly interactive multiplatform applications. Kivy's execution speed is comparable to the native mobile alternative, Java for Android or Objective C for iOS. Moreover, Kivy has the huge advantage of being able to run on multiple platforms, just as HTML5 does; in which case, Kivy performs better because it doesn't rely on a heavy browser, and many of its components are implemented in C using the Cython library in such a way that most of the graphics processing runs directly in the GPU. Kivy strikes a great balance between performance and portability across various hardware and software environments. Kivy emerges with a simple but ambitious goal in mind:

"… same code for every platform, at least what we use every day: Linux/Windows/Mac OS X/Android/iOS"

Mathieu Virbel (http://txzone.net/2011/01/kivy-next-pymt-on-android-step-1-done/)

This support has being extended to Raspberry Pi, thanks to a crowd funding campaign started by Mathieu Virbel, the creator of Kivy. Kivy was introduced for the first time at EuroPython 2011 as a Python framework designed for creating natural user interfaces. Since then, it has grown bigger and attracted an enthusiastic community.

This book requires some knowledge of Python, and very basic terminal skills, but also it requires some understanding of Object-Oriented Programming (OOP) concepts. In particular, it is assumed that you understand the concept of inheritance and the difference between instances and classes. Refer to the following table to review some of these concepts:

Before we start, you will need to install Kivy. The installation process for all different platforms is documented and regularly updated on the Kivy website: http://kivy.org/docs/installation/installation.html.

Note

All code in this book has been tested with Kivy 1.9.0 and both Python 2.7 and Python 3.4 (but 3.3 should work fine as well).

Note that packaging support for mobile is not yet complete for Python 3.3+. For now, if we want to create mobile apps for Android or iOS, we should use Python 2.7. If you want to know your Python version, you can execute python -V in a terminal to check your installed Python version.

In this chapter, we start by creating user interfaces using one of Kivy's most fun and powerful components – the Kivy language (.kv). The Kivy Language separates logic from presentation in order to keep an easy and intuitive code; it also links components at an interface level. In future chapters, you will also learn how to build and modify interfaces dynamically using pure Python code and Kivy as a library.

Here is a list of all the skills that you are about to learn:

  • Launching a Kivy application
  • Using the Kivy language
  • Instantiating and personalizing widgets (GUI components) through basic properties and variables
  • Differentiating between fixed, proportional, absolute, and relative coordinates
  • Creating responsive GUIs through layouts
  • Modularizing code in different files

This chapter covers all the basics for building a Graphical User Interface (GUI) in Kivy. First, we will learn techniques to run an application and how to use and integrate widgets. After that, we will introduce the main project of the book, the Comic Creator, and program the main structure of the GUI that we will continue using in the following two chapters. At the end of this chapter, you will be able to build a GUI starting from a pencil and paper sketch, and also learn some techniques to make the GUI responsive to the size of the window.

You have been reading a chapter from
Kivy ??? Interactive Applications and Games in Python second edition
Published in: Jun 2015
Publisher:
ISBN-13: 9781785286926
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image