Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Kivy Blueprints
  • Toc
  • feedback
Kivy Blueprints

Kivy Blueprints

By : Vasilkov
3.7 (10)
close
Kivy Blueprints

Kivy Blueprints

3.7 (10)
By: Vasilkov

Overview of this book

This book is intended for programmers who are comfortable with the Python language and who want to build desktop and mobile applications with rich GUI in Python with minimal hassle. Knowledge of Kivy is not strictly required—every aspect of the framework is described when it's first used.
Table of Contents (12 chapters)
close
10
A. The Python Ecosystem
11
Index

Hello, Kivy

When learning a new programming language or technology, the first thing demonstrated to students is traditionally a "hello, world" program. This is how it looks in Python:

print('hello, world')

The Kivy version of a "hello, world" is a little lengthier and consists of two files, namely, a Python module and a .kv layout definition.

Code

A Kivy application's entry point is customarily called main.py, and its contents are as follows:

from kivy.app import App

class HelloApp(App):
    pass

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

As you can see, this takes Kivy's App class, adds absolutely nothing to it, and calls run().

Layout

A layout file is typically named after the application class, in this case HelloApp, sans the App suffix and in lowercase: hello.kv. It contains the following lines:

Label:
    text: 'Hello, Kivy'

This is a very simple Kivy layout definition consisting of a single widget, Label, with the desired text inside. Layout files allow building complex widget hierarchies in a concise, declarative fashion, which is clearly not displayed here, but will be heavily used over the course of this book.

If we run the program now (refer to the Installing and running Kivy section for details), this is what we'll get:

Layout

Our first application powered by Kivy

Now you're ready to move on to the first chapter and start writing real programs.

bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete