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
Kivy Cookbook
Kivy Cookbook

Kivy Cookbook: Enhance your skills in developing multi-touch applications with Kivy

Arrow left icon
Profile Icon Solis Profile Icon Hugo Solis
Arrow right icon
Mex$1128.99
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.5 (2 Ratings)
Paperback Aug 2015 246 pages 1st Edition
eBook
Mex$179.99 Mex$902.99
Paperback
Mex$1128.99
Subscription
Free Trial
Arrow left icon
Profile Icon Solis Profile Icon Hugo Solis
Arrow right icon
Mex$1128.99
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.5 (2 Ratings)
Paperback Aug 2015 246 pages 1st Edition
eBook
Mex$179.99 Mex$902.99
Paperback
Mex$1128.99
Subscription
Free Trial
eBook
Mex$179.99 Mex$902.99
Paperback
Mex$1128.99
Subscription
Free Trial

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Kivy Cookbook

Chapter 1. Kivy and the Kv Language

In this first chapter, we will cover the following recipes:

  • Installing Kivy
  • Building your interfaces
  • Declaring properties within a class
  • Relating the Python code and the Kv language
  • Referencing widgets
  • Accessing widgets defined inside the Kv language in your Python code
  • Reusing styles in multiple widgets
  • Designing with the Kv language
  • Running your code
  • Using Kivy garden

Introduction

The first chapter is going to introduce the reader to the Kivy framework, its basis, and the Kv language. This is necessary work and a common base for the next chapters. If this is your first time using Kivy, it is advised that you do not skip this chapter. However, if you do, remember to return to this chapter if you need to install a supporting tool or verify any concept that you need to support your current solution.

Installing Kivy

This recipe will teach you how to install Kivy on a personal computer, which is the first step in starting to develop great software.

Getting ready

We will assume that you already have GNU/Linux (preferably Ubuntu/Debian/Trisquel, we recommend the last one) and Python installed on it. Usually, Python is already installed on the aforementioned GNU/Linux distributions. We will also assume that you are using Python version 2.7 or higher.

How to do it…

  1. Add one of the Personal Package Archives (PPAs) that you prefer; our recommendation is the following stable one:
    stable builds:  $ sudo add-apt-repository ppa:kivy- team/kivy
    nightly builds: $ sudo add-apt-repository ppa:kivy- team/kivy-daily
    
  2. Update your package list using your package manager:
      $ sudo apt-get update
    
  3. Install Python-kivy and, optionally, the examples that are found in Python-kivy-examples:
      $ sudo apt-get install Python-kivy
    
  4. Verify the installation. Call Python from the console and execute this command:
      import kivy

How it works…

There are many ways to get Kivy installed on your computer. Here we are describing probably the easiest way using your distribution's package manager. In the first step, we are adding a PPA as an APT repository to provide you with two different options: the stable one, for which all the Kivy products have been well tested, and the nightly one, which are packages under active development. Actually, for Ubuntu, you can skip the first step; it was just to get the latest version of Kivy.

In the second step, we update the list of available packages to include the Kivy repository. The third step is where the installation of Kivy really happens by using the distribution's package manager. In the last step, we verify if Kivy is working with the command that imports Kivy. If everything is OK we will see the following:

[INFO  ] Kivy v1.9.0

It shows the Kivy version that you installed in your system, which is v1.9.0 in this case. Remember to exit Python, for which we use the command quit().

There's more…

Now we will say something about Mac OS X and Microsoft Windows; for them, Kivy provides what is called portable packages. For an easy way to get Kivy running, just go to http://kivy.org/#download.

There's more…

Mac OS X

Download the dmg file, double-click to open it, and drag the Kivy.app into your Applications folder. Ready!

Mac OS X

You should run the make-symlinks script to make Kivy available in the shell system. Thus, you can run Kivy from the terminal.

Microsoft Windows

Download the .zip file and unzip it. There is a file named kivy.bat that must be copied as a shortcut into your SendTo folder.

See also

Well, if you are using a different operating system, you are always able to go to http://kivy.org/#download and look for the one that you are using. Also, if you want to build Kivy from the source code, refer to Chapter 8, Packaging our Apps for PC the recipe Packing for Linux.

Building your interfaces

Now we are going to create an interface, a very simple one, providing some basics in the developing of Kivy interfaces.

Getting ready

We are going to start to develop our first application with Kivy, and we need an editor for coding; you can use your favorite for Python without any problem. Here, we are using gedit, just because it comes with almost all GNU/Linux distros.

How to do it…

These steps will generate our first Kivy interface:

  1. Open a new file in gedit and save it as e1.py.
  2. Import the Kivy framework.
  3. Subclass the App class.
  4. Implement its build() method, so it returns a widget instance (the root of your widget tree).
  5. Instantiate this class and call its run() method.

The code for this is as follows:

import kivy
kivy.require('1.9.0') # Kivy ver where the code has been tested!

from kivy.app import App
from kivy.uix.label import Label

class MyApp(App):
    def build(self): 
        return Label(text='Hello world') 

if __name__ == '__main__':
    MyApp().run()

How it works…

Well, let's see the code in detail; the first line is:

import kivy

This does the magic of linking Python with Kivy. The second line is optional:

kivy.require('1.9.0')

However, it is extremely useful because it prevents version conflicts; if you have an old Kivy version, you will have to update to at least the version that is required. In the third line:

from kivy.app import App

It is required that the base class of your app inherits from the App class, which is present in the kivy_installation_dir/kivy/app.py folder. This is to connect your app with the Kivy GUI. The fourth line is:

from kivy.uix.label import Label

The uix module is the section that holds the user interface elements, such as layouts and widgets. This is a very common import that you will use in the future. Moving on to the fifth line:

class MyApp(App):

This is where we define the base class of our Kivy app. You should only ever need to change the name of your app MyApp in this line. The sixth line is:

def build(self):

This is the function where you should initialize and return your root widget. This is what we do on the seventh line:

return Label(text='Hello world')

Here we initialize a Label with the text Hello World and return its instance. This label is the root widget of this app.

Now, on to the portion that makes our app come to life is in the eighth and ninth lines:

if __name__ == '__main__':
MyApp().run()

Here, the class MyApp is initialized, and its run() method is called. This initializes and starts our Kivy app.

There's more…

Something to point out is the name of the window, it will be called My because of the name of the base class. Ergo, if you want the title of the window be Win1, your base class must be Win1App. So, the fifth line would be:

class Win1App(App):

You must change the last one to:

Win1App().run()

Actually, a suffix of App isn't necessary; it is just commonly used in Kivy. If you want to include an App suffix in the title or spaces, override the title attribute as:

class Win1App(App):
    def build(self): 
        self.title = 'Win 1 App'

See also

If you want to run your interface, take a look at our recipe Running your code. Also you can take a look in the file kivy_installation_dir/kivy/app.py, which is a very good document to go deeper into Kivy apps.

Declaring properties within a class

Here we want to highlight an important difference between traditional Python coding and Kivy, and the usefulness of this change.

Getting ready

We need to remember the traditional form to declare properties in Python. Usually, if we want to declare a property in Python, we do something such as:

class MyClass(object):
    def __init__(self):
        super(MyClass,self).__init__()
        self._numeric_var = 1
@property
    def numeric_var(self): 
        return self._numeric_var

We are declaring a numeric one, whereas if we use MyClass().numeric_var in the Python shell, we get 1 in return.

How to do it…

Now, to declare this property in Kivy we follow these steps:

  1. Import Kivy and its properties
  2. Define the class
  3. Reference the Kivy property, in this case the numeric one:
    import kivy
    
    from kivy.event import EventDispatcher
    from kivy.properties import *
    
    class MyClass(EventDispatcher):
        numeric_var = NumericProperty(1.0)

How it works…

The idea behind this is that you inherit the declaration from Kivy's properties, which reduces the number of code lines.

To use them, you have to declare them at a class level. That is, directly in the class, not in any method for the class. A property is a class attribute that will automatically create instance attributes. Each property, by default, provides an on_<propertyname> event that is called whenever the property's state/value changes.

Something additional to point out is that NumericProperty accepts all the Python numeric values: ints, floats, and longs.

In general, Kivy properties can be overridden easily when creating the instance of the class, using keyword arguments such as ClassName(property=newvalue).

There's more…

They help you to:

  • Easily manipulate widgets defined in the Kv language
  • Automatically observe any changes
  • Check and validate values
  • Optimize memory management

Kivy provides more properties as follows:

  • NumericProperty
  • StringProperty
  • ListProperty
  • ObjectProperty
  • BooleanProperty
  • BoundedNumericProperty
  • OptionProperty
  • ReferenceListProperty
  • AliasProperty
  • DictProperty

See also

These properties actually implement the Observer pattern; if you want to learn more about patterns, you can find information online at http://www.oodesign.com/observer-pattern.html.

Relating Python code and the Kv language

This recipe will teach you how to relate the Kv language to Python code. Kivy provides a design language specifically geared toward easy and scalable GUI design. The Kv language separates the interface design from the application logic, adhering to the separation of concerns principle, where the application remains in Python and the design remains in the Kv language.

Getting ready

This recipe will create the same interface as the recipe Building your interfaces, but now using the Kv language; hence, it could be educational to look the code in there to make some comparisons. Again we are using gedit, just because it comes with almost all GNU/Linux distros.

How to do it…

These steps will generate our Kivy interface using the Kv language:

  1. Open a new file in gedit and save it as e4.py.
  2. Make a rule for the label.
  3. Provide the text for the label:
    <Label>:
        text: 'Hello World' 
  4. Open a new file in gedit and save it as e4.py.
  5. Import the Kivy framework.
  6. Provide a subclass to the App class.
  7. Implement its build() method, so it returns a widget instance.
  8. Instantiate this class and call its run() method:
    import kivy
    kivy.require('1.9.0') # Kivy ver where the code has been tested!
    from kivy.app import App
    from kivy.uix.label import Label
    class e4App(App):
        def build(self): 
            return Label() 
    
    if __name__ == '__main__':
        e4App().run() 

How it works…

Well, let's see the code in detail. The first line for the file e4.kv is:

<Label>:

This line creates the rule for a Label. The second one is:

text: 'Hello World'

In this, we define the text property for the Label with the value 'Hello World'.

Now, the first four lines of the Python file are the common ones to use Kivy in Python, and we already reviewed them in this chapter recipe Building your Interfaces. Moving on to the fifth line:

class e4App(App):

This is where we define the base class of our Kivy app. You should only ever need to change the name of your app e4App in this line, and here is where the relationship between the Kv language and the Python code occurs. What happens is that Kivy looks for a file named e4.kv, which could be present or not. The sixth line is:

def build(self):

This is the function where you initialize and return your root widget. This is what we do on the seventh line:

return Label()

Here we initialize a Label and returned its instance. This Label is the root widget of this app, and it must be the same in the KV file.

Now, on to the portion that makes our app come to life is in the eighth and ninth lines:

if __name__ == '__main__':
    e4App().run() 

Here, the class e4App is initialized, and its run() method is called. This initializes and starts our Kivy app.

There's more…

The filename of the KV file should be such that adding the name of the KV file and App will become the name of the subclass of the App class. For example, if you change the name to Win1App, then you should also change the KV filename to Win1.kv.

Something to point out is that we can incorporate the KV code inside the Python file with the class Builder. We just add a few lines between the fourth and fifth lines in the Python code to import the Builder package and the override of the method as follows:

from kivy.lang import Builder
Builder.load_string('''
    <Label>: 
        text: 'Hello World' 
''')

See also

If you want to run your interface, take a look at our recipe Running your Code and compare the result with the recipe Building your Interfaces.

Referencing widgets

Sometimes, it is necessary to access or reference other widgets in a specific widget tree. In the Kv language, there is a way to do it using IDs.

Getting ready

This recipe will use two common widgets just for reference. The Button and TextInput fields are very common widgets.

How to do it…

This recipe is as follows:

  1. Make a rule
  2. Establish the ID
  3. Call the ID:
    <MyWidget>:
        Button: 
            id: f_but 
        TextInput: 
            text: f_but.state 

How it works…

Let's see the code; this is the first line:

<MyWidget>:

This is the name of the widget we will use, which is a clickable text input. The second line is:

Button:

This defines the button. The third line is:

id: f_but

This gives the button an ID of f_but, which we will use to reference the button. The fourth line is:

TextInput:

This defines the text input. The fifth line is:

text: f_but.state

This is the definition of the text that is in the text input where we are referencing the state of the button. It says that if you do not click the button, the text in the text input is normal, and if you click the button, the text in the text input is shown.

There's more…

An ID is limited in scope to the rule it is declared in, so in the preceding code, f_but cannot be accessed outside the <MyWidget> rule; that is, if we have a second <MyWidget2>, we are not able to reference f_but in <MyWidget2>.

Also ID is a weakref module for the widget and not the widget itself. As a consequence, storing the ID is not sufficient to keep the widget from being garbage collected. To demonstrate:

<MyWidget>:
    label_widget: label_widget.__self__ 
    Button: 
        text: 'Add Button' 
        on_press: root.add_widget(label_widget) 
    Button: 
        text: 'Remove Button' 
        on_press: root.remove_widget(label_widget) 
    Label: 
        id: label_widget 
        text: 'widget'

If we do not use ID.__self__ or in this case label_widget.__self__ just label_widget, we are going to get an error: ReferenceError: weakly-referenced object no longer exists.

See also

If you want to get more details about widgets, see the recipes in Chapter 4, Widgets.

Accessing widgets defined inside the Kv language in your Python code

This recipe will teach you how to access definitions inside the Kv language in your Python code and vice versa.

Getting ready

This recipe will use button, a very common widget that we also used in the last recipe.

How to do it…

This recipe follows as:

  1. Make a rule for the widget.
  2. Define a button.
  3. Give it an ID.
  4. Define the label for the button.
  5. In the action, call a method in the Python code:
    <MyW>:
        Button:
            id: b1
            text: 'Press to smash'
            on_release: root.b_smash()
  6. Create the Python code with the method:
    import kivy
    kivy.require('1.8.0') # replace with your current kivy version !
    
    from kivy.app import App
    from kivy.uix.widget import Widget
    
    class MyW(Widget):
        def b_smash(self):
            self.ids.b1.text = 'Pudding'
    
    class e7App(App):
        def build(self):
            return MyW()
    
    if __name__ == '__main__':
        e7App().run()

How it works…

In the Kv Language file, we have the following in the first line:

<MyW>:

This is the name of the widget, a simple button. The second line is:

Button:

This is the button definition. The third line is:

id: b1

This gives the button an ID b1. The fourth line is:

    text: 'Press to smash'

This makes the initial text on the button 'Press to smash'. The fifth line is:

    on_release: root.b_smash()

The preceding line is making a call to the Python code; it refers the method b_smash() of the root class MyW.

The fifth line in the Python code is:

class MyW(Widget):

This is the definition of the class related to the Widget. The sixth line is:

def b_smash(self):

This defines the method b_smash(), which is accessed by the Kv language file. The seventh line is:

self.ids.b1.text = 'Pudding'

This accesses the widget defined in the Kv language file, specifically the button with its ID, and changes the text displayed in the button to the text Pudding.

See also

If you want to run your interface, take a look at our recipe Running your code, and to get more details about widgets, see the recipes in Chapter 4, Widgets.

Reusing styles in multiple widgets

This recipe will teach you how to take advantage of reusing styles for different widgets, a procedure that could be useful for the scalability of a system.

Getting ready

We will use this example of a file, e8.kv, where two widgets are defined:

<MyWidget1>:
    Button: 
        on_press: self.text(txt_inpt.text) 
    TextInput: 
        id: txt_inpt 
<MyWidget2>: 
    Button: 
        on_press: self.text(txt_inpt.text) 
    TextInput: 
        id: txt_inpt

We must note that they are very similar, and actually just the name of the widget is different between them.

How to do it…

The following steps provide a way to join the two widgets:

  • Let's conserve just one of the widgets.
  • The name of the discarded widget will be added to name of the conserved widget, by separating with a comma:
    <MyWidget1,MyWidget2>:
        Button: 
            on_press: self.text(txt_inpt.text) 
        TextInput: 
            id: txt_inpt 

How it works…

In this case, by separating the class names with a comma, all the classes listed in the declaration will have the same KV properties and you could join any number of similar widgets.

There's more…

In the Python code, the widgets could do different tasks, as in the next portion of code:

class MyWidget1(Widget):
    def text(self, val):
        print('text input text is: {txt}'.format(txt=val)) 
class MyWidget2(Widget): 
    writing = StringProperty('') 
    def text(self, val): self.writing = val 

Similarly, you can join the widgets in the Kv language.

See also

If you want to get more details about widgets, see the recipes in Chapter 4, Widgets.

Designing with the Kv language

This recipe will give you a first look at the widgets' distribution and their interaction.

Getting ready

This recipe will use two common widgets, just for reference; again we'll be looking at the Button and TextInput fields. Also, a common kind of layout is BoxLayout, which controls the distribution of objects in the interface.

How to do it…

This recipe works by performing the following steps:

  1. First, the KV file:
    <Controller>:
        label_wid: my_custom_label
    
        BoxLayout:
            orientation: 'horizontal'
            padding: 20
    
            Button:
                text: 'My controller info is: ' + root.info
                on_press: root.do_action()
    
        Label:
          id: my_custom_label
          text: 'My label before button press'
  2. Next, the Python code:
    import kivy
    kivy.require('1.8.0')
    
    from kivy.uix.floatlayout import FloatLayout
    from kivy.app import App
    from kivy.properties import ObjectProperty, StringProperty
    
    class Controller(FloatLayout):
    
        label_wid = ObjectProperty()
        info = StringProperty()
    
        def do_action(self):
            self.label_wid.text = 'Button pressed'
            self.info = 'Bye'
    
    class e8App(App):
        def build(self):
            return Controller(info='Hello world')
    if __name__ == '__main__':
        e8App().run()

How it works…

If we are designing with the Kv language, let's see it in detail. In the first line:

<Controller>:

We are given the rule Controller, so remember that you are going to need a class Controller in your Python code. The second line is:

label_wid: my_custom_label

This code line gives defines the label for this rule from a reference to the Label. The third line is:

BoxLayout:

We start the definition of the properties for the layout. In the fourth and fifth lines:

    orientation: 'horizontal'
    padding: 20

We give values to the properties: in this case, horizontal to the orientation and 20 to the padding (the empty space beyond the border of the window). The sixth, seventh, and eighth lines are:

Button:
    text: 'My controller info is: ' + root.info
    on_press: root.do_action()

This is the definition for the button. Here is the most important part of the designing with the Kv language: the order in which it appears in the code is the same as that in which the widgets are arranged in the layout, so the button will be the leftmost of all the widgets that we will use. The final part of the code is the definition of the Label:

Label:
    id: my_custom_label
    text: 'My label before button press'

There's more…

An interesting modification can be done to the following fourth line of the KV file:

orientation: 'horizontal'

To change the orientation of BoxLayout from horizontal to vertical, we can change the preceding line to the following line:

orientation: 'vertical'

It will have the same functionality, but the button will be above the label.

See also

If you want more details about widgets and layouts, see the recipes in Chapter 4 , Widgets.

Running your code

In this recipe, we want to teach you how to run the code that we have constructed using the Kivy framework.

Getting ready

This recipe needs some code to be run and Kivy to be properly installed. We will use the code in the recipe Relating Python code and the Kv language, where we have two files, e4.kv and e4.py.

How to do it…

This recipe may seem easy because it is just a few steps, but the explanation is important. Use Python from the shell to run the file e4.py:

$ Python e4.py --size=250x200

It will display:

How to do it…

How it works…

As we've already seen in the recipe Relating Python code and the Kv language, the call to the e4.kv file occurs inside the e4.py code; as such, Kivy does not need an explicit reference. We used the option size previously because Kivy has a default size (usually 800x600 pixels) that did not meet our expectations.

There's more…

Well, if you are using a different operative system, there are some other considerations.

Mac OS X

With Mac OS X we use a portable package and we need to run the file a little bit differently:

$ kivy e4.py --size=250x200

This is because the Kivy framework has been packed with Python in the program call kivy.

Microsoft Windows

In Microsoft Windows, the portable package is called with a secondary click, using Send to menu, and selecting Kivy.

Microsoft Windows

See also

If you are interested in how to run your code on a mobile device, go to Chapter 9, Kivy for Mobile Devices.

Using Kivy garden

This recipe will teach you how to use Kivy garden, which is a helpful tool to get some Kivy add-ons.

Getting ready

This recipe needs the pip system, which is a package management system used to install and manage software packages written in Python. The installation is very easy: just go to https://pip.pypa.io/en/latest/installing.html and download get-pip.py. Now, in the terminal, type:

$ Python get-pip.py

This line installs pip.

How to do it…

These are the most important tasks with Kivy garden:

  1. Install Kivy garden:
    $ sudo pip install kivy-garden
    
  2. Install a garden package:
    $ garden install graph
    
  3. Upgrade a garden package:
    $ garden install --upgrade graph
    
  4. Uninstall a garden package:
    $ garden uninstall graph
    
  5. List all the garden packages installed:
    $ garden list
    

There's more…

Also, we want to be able to search in the Kivy garden; for example, we can:

  1. Search new packages:
    $ garden search
    
  2. Search all the packages that contain graph:
    $ garden search graph
    
  3. Show the following:
    $ garden --help
    

    All the garden packages are installed by default in ~/.kivy/garden.

Packing

If you want to include garden packages in your application, you can add the app to the install command. This will create a libs/garden directory in your current directory, which will be used by Kivy garden.

For example in my app, it is in the directory MyApp:

$ cd myapp
$ garden install --app graph
Left arrow icon Right arrow icon

Description

Kivy is an open-source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps. It is a promising Python framework to develop UI and UX apps in a cross-platform environment, under the Python philosophy. Kivy Cookbook is a practical book that will guide you through the Kivy framework to develop apps and get your apps ready for distribution in App Store and Android devices. You will start off with installing Kivy and building your interfaces. You will learn how to work the accelerometer and create custom events. Then, you will understand how to use the basics, buttons, labels and text inputs and manipulate the widget tree. Next, you will be able to work with manipulating instructions, create an atlas and layouts. Moving on, you will learn packing for Windows and packing for iOS, and use TestDrive. By the end of the book, you will have learnt in detail the relevant features and tools in Kivy and how to create portable packages to distribute your apps in the most used platforms.

What you will learn

  • Access widgets defined inside Kv language in your Python code Handle Kivy events to control widgets, touches, the mouse, the keyboard, and animations Recognize touch shapes and detecting multi-tapping Create custom events and declare properties Organizing your layouts while working with the ActionBar Store and retrieve the coordinate space context Create your own shader and render in a framebuffer Leverage Factory objects, multi-touch in iOS and multi-touch in Android
Estimated delivery fee Deliver to Mexico

Standard delivery 10 - 13 business days

Mex$149.95

Premium delivery 3 - 6 business days

Mex$299.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Aug 21, 2015
Length: 246 pages
Edition : 1st
Language : English
ISBN-13 : 9781783987382
Category :
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Mexico

Standard delivery 10 - 13 business days

Mex$149.95

Premium delivery 3 - 6 business days

Mex$299.95
(Includes tracking information)

Product Details

Publication date : Aug 21, 2015
Length: 246 pages
Edition : 1st
Language : English
ISBN-13 : 9781783987382
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Mex$85 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Mex$85 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total Mex$ 3,138.97
Kivy Blueprints
Mex$1004.99
Kivy Cookbook
Mex$1128.99
Kivy ??? Interactive Applications and Games in Python second edition
Mex$1004.99
Total Mex$ 3,138.97 Stars icon
Banner background image

Table of Contents

10 Chapters
1. Kivy and the Kv Language Chevron down icon Chevron up icon
2. Input, Motion, and Touch Chevron down icon Chevron up icon
3. Events Chevron down icon Chevron up icon
4. Widgets Chevron down icon Chevron up icon
5. Graphics – Canvas and Instructions Chevron down icon Chevron up icon
6. Advanced Graphics – Shaders and Rendering Chevron down icon Chevron up icon
7. The API in Detail Chevron down icon Chevron up icon
8. Packaging our Apps for PC Chevron down icon Chevron up icon
9. Kivy for Mobile Devices Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.5
(2 Ratings)
5 star 0%
4 star 50%
3 star 0%
2 star 0%
1 star 50%
SL Sep 10, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
This book covers Kivy for Python programmation language. Kivy helps you build graphical interfaces that run on all PC platforms and also on android and IOS. http://kivy.org/The cookbook format is quite convenient because it gives several recipes from extremely basic to more advanced ones. From launching a "hello world" app to packaging your app for distribution.So it's a good purchase and it was worth reading it.
Amazon Verified review Amazon
jooster Sep 07, 2017
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
I cannot recommend this book. Though the format fits my work/learning style, the example code is riddled with errors, problems and omissions. Right of the bat, the very first example (hello world) does not work as described. The remainder of the book is an exercise in frustration. I (tried to) made it through several examples before moving onto something else.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela