You are on page 1of 6

International Journal of Trend in Scientific Research and Development (IJTSRD)

Volume 7 Issue 4, July-August 2023 Available Online: www.ijtsrd.com e-ISSN: 2456 – 6470

Developing Online Application with Kivy: A Python Framework


Diksha Singla
Student, School of Engineering and Sciences, GD Goenka University, Sohna-Gurugram Rd, Sohna, Haryana, India

ABSTRACT How to cite this paper: Diksha Singla


Kivy is an open-source Python framework for building multi-touch "Developing Online Application with
applications on multiple platforms, including Android. This case Kivy: A Python Framework" Published
study provides an in-depth look at Kivy's capabilities and in International
demonstrates how to use this powerful framework to build Android Journal of Trend in
Scientific Research
apps. We discuss the main features, architecture and advantages of
and Development
Kivy for Android app development. In addition, we provide step-by- (ijtsrd), ISSN:
step instructions to create a simple Android application using Kivy 2456-6470,
and highlight the main features and capabilities. Through this Volume-7 | Issue-4, IJTSRD59687
research paper, developers and researchers will gain insight into August 2023,
Kivy's ability to build cross-platform apps on Android using Python. pp.504-509, URL:
www.ijtsrd.com/papers/ijtsrd59687.pdf
KEYWORDS: Kivy framework, Python, Application, Cross-platform,
Architecture, Android app, User Interface (UI) Copyright © 2023 by author (s) and
International Journal of Trend in
Scientific Research and Development
Journal. This is an
Open Access article
distributed under the
terms of the Creative Commons
Attribution License (CC BY 4.0)
(http://creativecommons.org/licenses/by/4.0)

INTRODUCTION
In today's digital age, mobile applications have We will delve deeper into user interface design,
become a part of our lives and enable us to do many dealing with user input, working with multimedia,
tasks and activities with ease. As the demand for and integrating communication and data storage. To
mobile apps continues to grow, developers are show Kivy in action, we'll provide a tutorial that
constantly looking for ways to simplify the app shows you the step-by-step development process of a
development process while maintaining simple Android app. This tutorial will provide insight
interoperability. into how to use the various features and highlight the
Kivy is an open-source Python framework that has power and flexibility of Kivy.
proven to be a great solution for building multi-touch Additionally, this research paper compares Kivy to
apps on multiple platforms, including Android. It other popular app development techniques,
allows developers to use the simplicity and flexibility highlighting its strengths and weaknesses. By
of the Python programming language to create understanding how Kivy differs from other
powerful and intuitive Android applications. frameworks, developers can make informed decisions
The purpose of this research paper is to enter the when choosing the most appropriate tool for a project.
world of Kivy and explore the potential of Android In summary, this case study is designed to give
application development. We will discuss the key developers and researchers an understanding of
concepts, architecture, and advantages that Kivy Kivy's ability to develop Android applications using
provides. Additionally, we will provide detailed Python. Developers can create integrated Android
instructions on how to build Android apps with Kivy, apps using Kivy's features and capabilities. With its
focusing on the main features and capabilities of the open nature and active community, Kivy provides a
framework. There are many advantages to using Kivy promising framework for building efficient and
to build Android apps with Python. Known for its intuitive Android apps.
readability, simplicity, and rich library, Python is an
excellent choice for developers who prefer high-level
languages.

@ IJTSRD | Unique Paper ID – IJTSRD59687 | Volume – 7 | Issue – 4 | Jul-Aug 2023 Page 504
International Journal of Trend in Scientific Research and Development @ www.ijtsrd.com eISSN: 2456-6470
KIVY FRAMEWORK: Kivy provides support for multiple platforms and
History and History of Kivy: operations, allowing developers to target a wider
Kivy was first released in 2011 by the development audience and ensure their apps run smoothly on
team led by Mathieu Virbel. It was originally created different devices. Overall, Kivy's architecture, design,
as part of the "PyMT" (Python Multi-Touch) project and cross-platform support make it a versatile
to provide a framework for building multi-touch framework for building applications with rich clients.
applications using Python. Over time, Kivy has Its modular design, separation of user interface and
evolved into a standalone framework focused on logic, and support for multiple platforms and
building cross-platform apps with rich user interfaces. functions have made it popular with developers who
want to build visual and interactive applications using
Architecture and Design Principles:
Kivy follows a flexible and extensible architecture. At Python.
its core, Kivy leverages the OpenGL ES graphics SETTING UP THE DEVELOPMENT
library to render and render images, making it ideal ENVIRONMENT:
for creating user-friendly interactive experiences. The Setting up the development environment for Kivy
framework also provides a variety of tools and design involves installing the framework and configuring the
methods, allowing developers to create complex user necessary tools and dependencies. Here are the steps
models. One of Kivy's key design principles is the to install and configure Kivy:
separation of the user interface (UI) from the
Install Python: Kivy requires Python to be installed
application logic. This is done using the Kivy (KV)
on your system. You can download the latest version
language, a declarative language to describe the
of Python from the official Python website
structure and appearance of user interfaces. By
(https://www.python.org) and follow the installation
separating UI design from code, Kivy allows
instructions for your operating system.
developers to focus on application logic and
facilitates easy collaboration between designers and Install Kivy: Once Python is installed, you can install
developers. Kivy follows an event-driven Kivy using pip, the package manager for Python.
programming model, where user interactions and Open a command prompt or terminal and run the
system events trigger specific actions in the following command:
application. Developers can define event handlers and This command will download and install the latest
bind them to specific UI elements, allowing them to version of Kivy along with its dependencies.
respond to user inputs and take appropriate action.
This approach can create interactive and responsive
applications.
Supported platforms and operating systems: Verify the installation: After the installation is
Kivy is designed as a cross-platform framework that complete, you can verify if Kivy is installed correctly.
supports various platforms and operating systems. Run the following command:
These include:
1. Android: Kivy provides native support for
Android, allowing developers to build and deploy
apps directly to devices. If Kivy is installed properly, you should see the Kivy
2. iOS: Kivy also supports iOS, allowing developers logo and version information displayed in the
to create apps for iPhones and iPad. However, terminal or command prompt.
iOS support requires additional setup and tools Set up a text editor or IDE: Choose a text editor or
due to Apple restrictions. integrated development environment (IDE) to write
3. Windows: Kivy is compatible with the Windows your Kivy code. Popular options include Visual
operating system and allows developers to create Studio Code, PyCharm, Sublime Text, and Atom.
applications for desktops and tablets running Configure the editor or IDE according to your
Windows. preferences.
4. macOS: Kivy supports macOS, allowing Additional tools and dependencies: Depending on
developers to create apps for Apple desktops and your specific needs and the features you plan to
laptops. incorporate into your Kivy app, you may need to
install additional tools and dependencies. Here are
5. Linux: Kivy has strong support for Linux
some commonly used tools:
distributions, making it possible to build
applications for many Linux-based platforms.

@ IJTSRD | Unique Paper ID – IJTSRD59687 | Volume – 7 | Issue – 4 | Jul-Aug 2023 Page 505
International Journal of Trend in Scientific Research and Development @ www.ijtsrd.com eISSN: 2456-6470
Buildozer: Buildozer is a tool that helps package hierarchically using layouts to create complex UI
your Kivy app into a standalone APK for structures.
Android. You can install it by running the
Event Handling:
following command:
Kivy uses an event-driven architecture, where events
trigger specific actions in the application. Event
handlers can be defined to respond to user
Pygame: If you plan to use sound or music in interactions, such as button clicks or touch events.
your Kivy app, you may need to install Pygame. These event handlers are typically defined within the
Run the following command to install it: App class or within individual widgets.
The Role of the main.py File:
The main.py file plays a crucial role in a Kivy
Cython: If you encounter any performance issues application. It serves as the entry point for the
or need to optimize your Kivy app, you can install application, where the app instance is created and the
Cython. Run the following command to install it: main loop is started. The main.py file typically
includes the following tasks:
Importing Dependencies:
The main.py file begins with importing the necessary
Additional libraries: Depending on your app Kivy modules and any additional Python libraries
requirements, you may need to install additional required by the app.
Python libraries. You can use pip to install these
libraries as needed. App Initialization:
An instance of the App class is created by subclassing
Once you have completed these steps, your it in the main.py file. This subclass typically includes
development environment is set up and ready to start the build() method, which returns the root widget of
building Kivy applications. You can create a new the application. The build method defines the initial
Python file, import the necessary Kivy modules, and user interface structure of the app.
begin writing your app code using the Kivy
framework and its features. Running the App:
After the app instance is created, the main.py file
Kivy App Structure: calls the run() method on the app instance. This
The structure of a Kivy app consists of multiple method starts the Kivy event loop, which listens for
components that work together to create the user user input and updates the UI accordingly. The app
interface and define the application's behaviour. Here will continue to run until the user closes the
is an overview of the app structure in Kivy: application window or the main loop is explicitly
Main Entry Point (main.py): stopped.
The main.py file serves as the entry point of the Kivy Organizing the User Interface with .kv Files:
application. It typically contains the code that Kivy provides a special file format called Kivy
initializes the app and starts the main loop. This file is Language (KV) for organizing and defining the user
responsible for creating the app instance and running interface. KV files have a .kv extension and allow for
it. declarative UI design, separating the UI structure and
App Class: appearance from the Python code.
In Kivy, the core of the application is defined by an KV files provide a concise and expressive syntax for
App class that inherits from the kivy.app.App class. defining widgets, layouts, and other UI elements.
This class represents the application and provides the They can be loaded automatically by Kivy based on
main functionality. It typically contains methods such naming conventions or explicitly loaded using the
as build() (to define the root widget of the app) and Builder class.
event handlers for various app-level events.
The use of KV files allows for a clean separation of
User Interface (UI): UI design and logic, making it easier to collaborate
The user interface of a Kivy app is defined using a between designers and developers. KV files can be
combination of Python code and .kv files. The UI used to define the structure of the UI, set properties of
consists of widgets, layouts, and other graphical widgets, define event handlers, and apply styles and
elements that define the visual representation and themes.
interaction of the app. Widgets can be organized

@ IJTSRD | Unique Paper ID – IJTSRD59687 | Volume – 7 | Issue – 4 | Jul-Aug 2023 Page 506
International Journal of Trend in Scientific Research and Development @ www.ijtsrd.com eISSN: 2456-6470
To organize the user interface with .kv files, you
typically create a separate .kv file for each screen or
section of your app. Within the .kv files, you define
the UI structure using widgets and layouts, set
properties and attributes and define event handlers
using the Kivy language syntax.
In the main.py file, you can load the appropriate KV
file using the Builder.load_file() method or let Kivy
automatically load the corresponding KV file based
on naming conventions. The loaded KV file will
define the user interface structure for that particular
screen or section of your app.
CODE: Student Information Input with Kivy Grid
Layout

This code imports necessary modules from the Kivy


library and defines a basic Kivy app with a
GridLayout containing a Label, TextInput, and
Button. The app prompts the user to enter their name
and includes a button to submit the input.
The code defines a Kivy app with a custom widget
called SpartanGrid. The SpartanGrid class inherits
from the GridLayout class provided by Kivy. In its
constructor (__init__), the grid layout is set to have 2
columns, and several UI components are added to the
grid using the add_widget() method. These
components include labels, text input fields, and a
The code defines a simple Kivy app called button.
SpartanApp. The build() method is overridden to
When the button is pressed, the click_me() method is
create the app's user interface, which consists of a
called. This method retrieves the text entered in the
single Label widget displaying the text "This is
text input fields and prints them to the console.
Spartaaaaaa!!!!!". When the app is run, an instance of
SpartanApp is created, and the run() method is called The SpartanApp class is the main app class that
to start the app's main loop, displaying the label on inherits from the App class. In its build() method, an
the screen. This code demonstrates the basic structure instance of SpartanGrid is created and returned as the
of a Kivy app, where the build() method is used to root widget of the app.
define the app's UI components. When the app is run, an instance of SpartanApp is
created, and the run() method is called, which starts
the app's main loop. The app displays the grid layout
with labels, text input fields, and a button. When the
button is clicked, the entered student name, marks,
and gender are printed to the console.
This code demonstrates a more complex UI structure
using a custom grid layout and showcases how to
retrieve and use user input in a Kivy app.

@ IJTSRD | Unique Paper ID – IJTSRD59687 | Volume – 7 | Issue – 4 | Jul-Aug 2023 Page 507
International Journal of Trend in Scientific Research and Development @ www.ijtsrd.com eISSN: 2456-6470
COMPARISON WITH OTHER 2. Weaknesses of Kivy: Native Android
FRAMEWORKS: development offers the highest level of
When comparing Kivy with other Android app performance and access to all native Android
development frameworks, it's important to consider APIs and features. Native apps can take full
factors such as ease of use, performance, community advantage of platform-specific optimizations and
support, and platform compatibility. Here are some provide a seamless user experience. Kivy, while
popular frameworks that are commonly compared to offering cross-platform capabilities, may face
Kivy, along with their strengths and weaknesses: limitations when it comes to accessing certain
platform-specific features or optimizing
Kivy vs. Flutter:
performance to the same extent as a native app.
1. Strengths of Kivy: Kivy offers the advantage of
using Python, which is known for its simplicity Kivy stands out for its cross-platform support, ease of
and readability. It provides cross-platform use for Python developers, and active community. It
support, enabling developers to build apps for provides a viable option for building Android apps
multiple platforms using a single codebase. Kivy with Python. However, compared to frameworks like
also has a mature and active community, offering Flutter and React Native, Kivy may have a steeper
extensive documentation and resources. learning curve and could face limitations in terms of
performance and native-like UI. The choice of
2. Weaknesses of Kivy: Compared to Flutter, Kivy
framework ultimately depends on the specific
may have a steeper learning curve for beginners.
requirements of the project, the development team's
Flutter has gained significant popularity in the
skills, and the desired balance between development
Android development community, and it has a
speed and native performance.
larger ecosystem with a wide range of libraries
and plugins. Additionally, Kivy's performance CONCLUSION:
may not match the native performance of Flutter, Summary of Key Findings:
especially for complex UI animations and In this research paper, we explored Kivy, an open-
transitions. source Python framework for building Android apps.
We discussed its background, architecture, and design
Kivy vs. React Native:
principles. Kivy's strengths lie in its ability to create
1. Strengths of Kivy: Kivy's main strength lies in
visually appealing and interactive user interfaces, its
its ability to use Python, which has a large and
cross-platform compatibility, and its extensive
established developer community. It offers a more
community support. The framework provides a wide
familiar programming language for Python
range of features for UI design, user input handling,
developers. Kivy also provides a more
multimedia integration, and networking. We also
comprehensive set of UI components and built-in
compared Kivy with other popular frameworks,
widgets compared to React Native.
highlighting its advantages and weaknesses.
2. Weaknesses of Kivy: React Native has gained
substantial popularity in the mobile app Future Directions and Potential Enhancements:
As Kivy continues to evolve, there are several
development landscape due to its performance,
potential directions for future enhancements:
native-like look and feel, and extensive
community support. React Native also benefits Performance Optimization: Further
improvements in Kivy's performance can make it
from the vast ecosystem of JavaScript libraries
even more competitive with native app
and modules, making it easier to integrate with
development. Optimizations in rendering,
existing web technologies. Kivy, on the other
animations, and transitions can help provide
hand, may face challenges when it comes to
smoother user experiences.
performance optimization and accessing native
device features. Enhanced Native Integration: Strengthening the
integration with native Android APIs and features
Kivy vs. Native Android Development:
1. Strengths of Kivy: Kivy's primary advantage can expand the capabilities of Kivy apps. This
could involve providing easier access to platform-
over native Android development is its cross-
platform compatibility. It allows developers to specific functionalities or simplifying the process
of integrating with native libraries.
write code once and deploy it on multiple
platforms, saving time and effort. Kivy also Tooling and Development Workflow:
provides a simplified UI development process Improvements in development tools, debugging
with its declarative KV language. capabilities, and IDE integrations can enhance the

@ IJTSRD | Unique Paper ID – IJTSRD59687 | Volume – 7 | Issue – 4 | Jul-Aug 2023 Page 508
International Journal of Trend in Scientific Research and Development @ www.ijtsrd.com eISSN: 2456-6470
development workflow and make it more efficient rewarding journey of building engaging Android apps
for developers working with Kivy. with Python.
Community Expansion: Continued growth and REFERENCES:
engagement within the Kivy community can [1] Hansen, T., Hourcade, JP., Virbel, M., Patali,
foster the creation of more resources, tutorials, S., Serra, Tiago., PyMT: a post-WIMP multi-
and examples, further supporting developers and touch user interface toolkit. ACM International
encouraging the adoption of Kivy. Conference on Interactive Tabletops and
Surfaces, Banf, Canada, 2009.
Encouragement for Further Exploration and
Experimentation: [2] Kaltenbrunner, M., Bovermann, T., Bencina,
Kivy offers a unique approach to Android app R., Constanza, E. TUIO – A Protocol for Table
development with its Python-based framework. It Based Tangible User Interfaces. Proc. 6th
provides developers with a flexible and powerful International Workshop on Gesture in Human-
toolset to create visually stunning and cross-platform Computer Interaction and Simulation, Vannes,
applications. We encourage developers to further France.
explore and experiment with Kivy, leveraging its
[3] Lobunets, O., Prinz, W. Exploring cross-
features and community support to build innovative
surface applications development using up-to-
and engaging Android apps.
date Web technologies. Submitted to
By diving into the extensive documentation, Interactive Table tops and Surfaces 2011,
exploring code examples, and actively participating in Kobe, Japan, 2011.
the Kivy community, developers can gain a deeper
[4] Rigo, A., Pedroni, S. PyPy's approach to virtual
understanding of the framework and unlock its full
machine construction. Companion to the 21st
potential. Additionally, developers can contribute to
ACM SIGPLAN symposium on Object-
the framework by reporting bugs, contributing code,
oriented programming systems, languages, and
or sharing their experiences, thereby contributing to
applications, Portland, Oregon, USA, 2006.
the growth and improvement of Kivy.
[5] Tissoires, B., Conversy, S., Graphic Rendering
In conclusion, Kivy opens up exciting possibilities for
Considered as a Compilation Chain, ENAC,
Android app development using Python. It empowers
Toulouse, France, 2008.
developers to create beautiful and interactive user
interfaces while maintaining cross-platform [6] Tissoires, B., Conversy, S., Hayaku: Desigining
compatibility. By embracing Kivy and embracing its and Optimizing Finely Tuned and Portable
vibrant community, developers can embark on a Interactive Graphics with a Graphical
Compiler.

@ IJTSRD | Unique Paper ID – IJTSRD59687 | Volume – 7 | Issue – 4 | Jul-Aug 2023 Page 509

You might also like