Python Kivy Tutorial For Beginners – Getting Started

Hello programmers, are you interested in app development using python, then welcome to Python Kivy Tutorial For Beginners. In this tutorial, you will learn what is kivy, where it is used, and how to work with it in python. So let’s gets started. 

Python Kivy Tutorial For Beginners – An Introduction To Kivy

What Is Kivy ?

  • Kivy is a graphical user interface Python library that allows you to develop multi platform applications on Windows, MacOS, Android, iOS, Linux, and Raspberry Pi.
  • What is better is that it performs better than HTML5 cross platform alternatives. 
  • It can natively use most inputs, protocols and devices including WM_Touch, WM_Pen, Mac OS X Trackpad and Magic Mouse, Mtdev, Linux Kernel HID, TUIO. A multi-touch mouse simulator is included.
  • The best thing of kivy is that this framework is stable and has a well documented API, plus a programming guide to help you get started.

Prerequisites

If you want to learn kivy then you must have basic knowledge of following :

  • Python
  • Concepts of OOPS

Python Kivy Tutorial For Beginners – Installing Kivy 

To use kivy, we have to download and install it. In this tutorial i am using windows so i will show you how to install kivy on windows. Anyway if you want to install it on any other OS then visit kivy’s official website. By following this site you can easily install it on your machine. So let’s do it on windows OS.

 I assume that you have already installed python and pip on your machine. If not then check them first :

Python Django Tutorial for Beginners – Getting Started

How to install pip on windows

1. Update the pip and wheel before installing kivy

Now open your command prompt and run following command.

While executing it looks like following.

Python Kivy Tutorial For Beginners
Python Kivy Tutorial For Beginners

2. Installing  Dependencies

Now install dependency by executing following commands.

Python Kivy Tutorial For Beginners
Python Kivy Tutorial For Beginners
  • Now run the following command.

  • Now install one other dependency. Run the following command.

3. Installing kivy

Now install the kivy by executing following command.

4. Installing PyGame

Since PyGame is a dependency of Kivy, we’ll grab that first. PyGame is one of the original packages for creating games in Python. So now run following command.

So we have installed all dependencies successfully and now it’s time to create our first app in kivy. So let’s gets started.

Python Kivy Tutorial For Beginners – Creating First App

So are you ready to create your app? yes then let’s do it. 

Importing Modules 

The first thing we need to do is to install some modules. So write the following code on your editor(Here i am using Sublime Text 3, you can check this How to run python code on Sublime Text 3 ?).

Creating Class To Represent Our Window

Now we will create a class that will represent our window. So write the following code.

  • MyFirstKivyApp inherits all the fields and methods from Kivy.
  • build()  returns the content we want to place on the window.
  • In the code above, we have returned a label widget with text “Welcome To Kivy World”.

Running Our App

So now to make run our program we need to write the following code.

Complete Code Of My First App

So here is the complete code for the above code snippets. It looks like as below.

Now run the above code. Are you excited to see your first kivy application, then what are waiting for? let’s see.

Python Kivy Tutorial For Beginners
Python Kivy Tutorial For Beginners

Hey congratulations, we have created our first kivy application successfully. Have you enjoyed it? Let me know in comment section.

 So guys this was all about Python Kivy Tutorial For Beginners. I hope you have enjoyed it and learned lots of useful stuffs. If yes then just help your friends by sharing this. And if you have any problem regarding this post then feel free to comment. In upcoming tutorial, you will get more kivy tutorials till then stay connected with Simplified Python. Thanks Everyone.

Also Check

Leave a Comment