Introduction to Kivy; A Cross-platform Python Framework

PythonServer Side ProgrammingProgramming

In this article, we will learn about Kivy framework and its installation. Kivy is a GUI based application interface, open-source that helps in cross-platform applications for Windows, Linux and Mac.

Installation Guide

Firstly we need to install python on pc.

After that we need to install the dependencies −

Windows −

>>> python -m pip install docutils pygments pypiwin32kivy.deps.sdl2 kivy.deps.glew
>>> python -m pip install kivy.deps.gstreamer
>>> python -m pip install kivy.deps.angle

Linux −

$ sudo add-apt-repository ppa:kivy-team/kivy

Installing the Kivy file

Windows −

>>> python -m pip install kivy

Linux −

>>> sudo apt-get install python3-kivy

Now let’s see how we can make a graphical user interface using Kivy −

Example

import kivy
kivy.require('1.10.0')
from kivy.app import App # gui interface creator
from kivy.uix.button import Label # button label import statement
class Sample(App):
   # display content on screen
   def build(self):
   # Return a label widget with Sample
   return Label(text ="Tutorialpoint")
sample = Sample()
sample.run()

Output

A new window popup will be displayed with the title of Sample containing text “Tutorialspoint” in it .

A window popup will be observed on the screen

In this manner we can use Kivy to create a GUI badsed application in Python

Conclusion

In this article, we learnt about the use of kivy framework for the creation of GUI based application.

raja
Published on 28-Aug-2019 13:56:32
Advertisements