Kivy python tutorial – Build your first app

kivy python tutorials

Introduction to kivy python

We know that the most popular programming language is “Python”. But the fact is python doesn’t have any built-in functionalities for mobile development. The biggest advantage of python is the largest community and that helps to expand the functionalities of python in all areas. Fourtunately kivy python helps you to built apps.

Kivy is an opensource library for creating cross-platform GUIs. This cross-platform functionality enables kivy python apps to run on all desktop platforms like mac, windows, and Linux OS  and also mobile platforms like Android & iOS easily.

kivy was released in 2011. It supports multi-touch events in addition to regular events like keyboard and mouse inputs. kivy also supports graphics. This project uses the MIT license so we can use it for free and commercial use. The greatest thing is you don’t need any platform specialization for kivy app development like iOS (SWIFT). The only requirement is Python.

Installation of Kivy python

if you are familiar with python programming, we oftenly use pip command for package installation. Now the same way we do it for kivy installation. Its better to update pip whenerver we get updates or else use below command.

python -m pip install --upgrade pip wheel setuptools virtualenv

whenever we start a project or we learn something new, its better to create virtual environment that can help you for deployment and share your project. follow the below command to create “kivy”<user defined> virtual environment.

python -m virtualenv kivy_venv

now activate your virtual environment if you are using windows, check on the internet for other OS.

workon kivy_venv

Before going to install kivy we need install kivy dependencies by following command.

 

python -m pip install docutils pygments pypiwin32 kivy_deps.sdl2==0.1.* kivy_deps.glew==0.1.* 

python -m pip install kivy_deps.gstreamer==0.1.*

Now install kivy by following command. at the time post published stabled virsion of kivy is kivy==1.11.1, you can check the latest stabled version here

python -m pip install kivy==1.11.1

Build your first kivy app

After completion of above steps follow me to build your first kivy python application. This is our first kivy python tutorial.let me explain the below code, we import kivy , App and Label for print text as output as below.

we create a class MyApp and we inherit the App class and we define a function build that returns our text as output on screen like below.

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

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

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

Follow us to get more simplified kivy python tutorials . check out our all other courses here

Don't miss out!
Subscribe To Newsletter

Receive top Machine learning & Python news, lesson ideas, project tips, FREE Ebooks and more!

Invalid email address
Thanks for subscribing!

Leave a Reply