Skip to content
Home » Kivy Part 2 – Environment Setup

Kivy Part 2 – Environment Setup

Spread the love

Now that we know what we want to do, the question is: how to do it and what software to use? We will need a minimum of two things: Kivy itself and a text editor or IDE where we can edit our code. This is all we need for our environment setup.

But before we delve into the topic, here’s some info for you.

*****

Book Info

I just published my Kivy book, GUI Programming with Python and Kivy. It’s pretty long (over 800 pages) and comprehensive. And, which also counts, easy to read. The book contains lots of illustrations.

This book covers all the basics that you need to know to start programming GUI applications with Python and Kivy. Throughout the book we are building a GUI application from scratch, a fully functional game using all kinds of tools that Kivy has to offer. It’s our Slugrace project, but covered in a much more in-depth manner.

Each part of the book starts with a theoretical introduction of a topic or idea that we then implement in the project. I assume you have no prior knowledge of the Kivy library, but you should have at least some basic knowledge of the Python programming language, including the object-oriented programming paradigm as this is what we will be using a lot in this book.

Kivy book

The book covers all the basic elements of Kivy that you have to know, like widgets, layouts, Kivy ids and properties, graphics, screens, animation, sound. Finally we’ll deploy the app to Windows. It is pretty comprehensive and after you finish it, I’m sure you’ll be able to create your own awesome GUI apps of any kind, not just games.

I hope you will have at least as much fun reading the book as I had writing it.

As far as this Kivy series is concerned, the following parts will contain the most important elements covered in the book. However, some elements will be presented in a simplified way here on my blog or omitted completely.

____________

If you are interested, you can purchase the book in four versions. Here are the links:

1) ebook – pdf version on my website – in full color

Here you can see the description of the book, sample graphics from the book and the full table of contents.

2) ebook – Kindle version on Amazon – in full color

3) paperback version on Amazon – in black and white

4) paperback version on Amazon – in full color

*****

And Now Let’s Move On…

The Kivy Library – the First Element of Our Environment Setup

Let’s start the environment setup with Kivy. Kivy is an open source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps. Well, this is what you can read on kivy.org, not my words. So, I suggest you visit the page and read more about Kivy if you’re interested and when you are ready, we can install Kivy.

This may change, but at the time of writing this is what it looks like when you go to the Help tab. Now click on Getting Started with Kivy:

The Kivy Library - the First Element of Our Environment Setup

In the sidebar select Installation (A). You can now download Kivy from the link you can see near the top of the page (B).

kivy installation

After that click on the icon of your platform for further instructions. I use Windows, so I’ll click on the first icon. There are a couple of options, depending on whether you use Conda or not for example. I wouldn’t be able to explain to you how to install Kivy in a better way than you will find on their website. The information you can find there is also up-to-date, which is also important. Therefore, I’m going to stop here and you can now take your time to read the instructions and install Kivy on your platform. For the next steps I assume you have Kivy installed on your system.

Your Panda3D Magazine

Make Awesome Games and Other 3D Apps

with Panda3D and Blender using Python.

Cool stuff, easy to follow articles.

Get the magazine here (PDF).

The Visual Studio Code Text Editor

The next thing we’re going to need for our environment setup is a text editor. I’m going to use Visual Studio Code. You can use any editor or IDE of your choice, but if you want to follow along and use the exact same editor as I do, just feel free to download and install it from their website (code.visualstudio.com). The installation is pretty straightforward, so I’m sure you’ll be able to do it in no time.

Now, with Visual Studio Code installed, open it. Now, your Visual Studio Code editor will probably have a dark theme, with which it comes as a default. I like the light theme better, so I changed it in the settings, but you can choose any theme you like.

Python Jumpstart Course

Learn the basics of Python, including OOP.

with lots of exercises, easy to follow

The course is available on Udemy.

Extensions

In order to use Kivy and Python in Visual Studio Code, we’ll need at least the Python extension. Click on Extensions (A) and then type in ‘python’ in the search box (B). Then install the first extension in the results list by clicking on the Install button. You can’t see the button here on the screenshot because the extension is already installed on my machine.

Visual Studio Code - the second element of the environment setup

Generally, this would be it. You’re ready to start coding. But there is one more extension worth installing.

When you work with Kivy you can either write everything in Python code or you can separate the logic of your application from its graphical interface. Separation of concerns is the way to go in most cases (except for the most trivial ones) and as our application is not going to be extremely trivial, let’s go for the latter option. We’ll be using Python for the logic and for the layout we’ll be using the Kivy language. It’s a special language designed for Kivy that makes the separation very clear and simple. Don’t be afraid, it’s not difficult and you will appreciate going this way very soon.

There is an extension in Visual Studio Code that you can install. This will turn on syntax coloring for example and generally make your work with the Kivy language much easier and more pleasurable. Just like before, type in the name of the extension (‘Kivy’) in the search box (A) and install the extension by clicking on the Install button. As before, I already have the extension installed on my computer.

kivy extension in VSC

Now, with the Kivy library installed and the text editor installed, along with the two extensions, you’re ready to get your feet wet by writing some simple Kivy code. In the next part we’ll be writing a basic Kivy application.

Blender Jumpstart Course

Learn the basics of 3D modeling in Blender.

step-by-step, easy to follow, visually rich

The course is available on Udemy and on Skillshare.


Spread the love

Leave a Reply