SkillRary

Por favor inicia sesión para publicar comentario

Introduction to KIVY

  • Amruta Bhaskar
  • Aug 18, 2020
  • 0 comentario (s)
  • 2486 Puntos de vista

Kivy is an open-source and graphical user interface development platform for Python. It helps to develop mobile applications and multi-touch application software with Natural User Interface (NUI). It allows the developers to build the application once and use it across all the devices. It accesses mobile API’s to manipulate things like a camera on a phone, GPS tracking etc.

Components it contains for creating an application:

1.   A graphical library OpenGL ES 2.

2.   An extensive range of widgets that support multi-touch.

3.   An intermediate Kv language to design custom widgets.

4.   Extensive support for input devices such as a mouse, keyboard, TUIO, as well as OS-specific multi touches events.

Features:

1.   Video: It includes various modules to play video files and streams. Kivy video player supports some requirements related to videos such as play, pause, stop buttons, text that can be used as a subtitle, display messages to the user on videos, and more.

Eg: pygame video provider supports MPEG1 on Linux.

2.   Multi-touch and gestures: It uses a wide range of widgets that support multi-touch and gestures. The developers of Kivy provide a gesture library to record the user's gesture.

There are three gestures that we can record –

·        Left to right horizontal line

·        Right to left horizontal line

·        Bottom to top vertical line

3.   UI features: It comes with a number of widgets and controls to make our mobile interface more attractive and beautiful. It is used to improve one-handed usability, create new icons or design elements, navigate gestures, dark mode, and new animations.

4.   Visual effects and OpenGL: It uses PyGame for easily creating new games. PyGame comes with various modules to drawing shapes, dealing with colours and playing music.

5.   Flexible: It is more flexible because it can run on a variety of devices like Linux, mobile phones, windows, tablets, iOS, and Raspberry Pi. It is flexible because it can adapt to new technologies quickly.

6.   Free: Its framework is free to use. To work with Kivy framework, you must have 1 GHz 32 bit (x86), or 64 bit (x64) CPU, 1 GB of RAM, 128 MB of graphical memory, and Python installed on your system.

Advantages:

1.   With multi-touch functionalities, it helps to design innovative user interfaces.

2.   Provides well document API’s.

3.   Helps to run code on all platforms.

4.   It smoothly works with platforms like Windows, Android, Linux, iOS, macOS, and Raspberry Pi.

5.   Offers a better representation of program like classes, widget configuration, and inherited classes.

Disadvantages:

1.   It uses kV language, which is not suitable to compile the code alone.

2.   It is not up-to-date with the latest Android APIs.

3.   Takes a lot of time for building and compiling mobile applications.

4.   The sizes of the package are huge.

5.   Lack of community support.

 


KIVY ARCHITECTURE:

 

1.  

  1. Core providers and Input providers: Modularity and Abstraction is the key to understanding Kivy’s internals. We abstract basic tasks like opening a window, playing audio, displaying images and text, getting images from a camera, spelling correction etc. These are called core tasks and makes API both easy to use and extend. A piece of code that uses one of the APIs to talk to the operating system on one side and Kivy on the other i.e., acting as an intermediate communication layer is called core provider. The same concept is followed by input handling. An input provider is a piece of code that adds support to specific input device like Apple’s trackpads, TUIO or a mouse emulator. If you want to add support for a new input device, you can provide a new class that reads your input data from your device and transforms them into Kivy basic events.
  2. Graphics: Graphics APIs Kivy has the ability to automatically optimize the drawing commands.
  3. Core: The code in the core package provides commonly used features, such as:

·        Clock: The clock is used to schedule timer events. One-shot timers and periodic timers are both supported.

·        Cache: When you need to cache something that you often use, you can use the class for that instead of writing your own.

·        Gesture Detection: Provides simple gesture recognizer that you can use to detect different kinds of strokes, like circles or rectangles.

·        Kivy Language: The kivy language is used to easily and efficiently to describe user interfaces.

·        Properties: They are not normal properties that you may know from python. They are the own property classes that link your widget code with the user interface description.

4.   UIX: This contains widgets and layouts that are commonly used.

Widgets are user interface elements that are added to the program to provide some kind of functionality. They may or may not be visible. Widgets receive MotionEvents.

Ex: file browser, buttons, sliders, lists and so on.

Layouts are used to arrange widgets. It is possible to calculate your widgets’ positions by yourself, but often it is more convenient to use one of our readymade layouts. You can also nest layouts.

Ex: Grid Layouts or Box Layouts.

5.   Modules: If you have ever used a modern web browser and customized it with some add-ons then you know the basic idea behind our module classes. They are used to inject functionality into Kivy programs, even if the original author did not include it.

Ex: module that always shows the FPS of the current application and some graph depicting the FPS over time.

6.   Input Events: In the kivy Architecture, the Kivy Input events play an important role. Kivy abstract contains different input events like touches, mice, TUIO, Mouse, MTDev, and HIDInput.

Input types are characterized by an instance of the touch () class. A touch () class instance can be one of the following three states.

·        Down

·        Move

·        Up

 

7.   Widgets and input dispatching: Widgets are frequently used in GUI programming to describe that part of the program which interacts with a user. In kivy, widgets work as an object that receives input events. Widgets are arranged in the form of a widget tree. A widget may contain any number of child or none.

 


Por favor inicia sesión para publicar comentario

( 0 ) comentario (s)