πŸ“±

Kivy App Development Basics

Jul 29, 2025

Overview

This lecture introduces beginner app development using Python and the Kivy framework, guiding students through creating a simple data entry application from scratch.

Introduction to Kivy and Python App Development

  • Python can be used to develop cross-platform apps using the Kivy library.
  • Kivy is an open-source Python library designed for rapid application development with innovative user interfaces like multi-touch.
  • Kivy supports Windows, Linux, macOS, Android, iOS, and Raspberry Pi.

Setting Up the Project

  • Use your preferred code editor to create a new Python project and file (e.g., new_app.py).
  • Install the Kivy module via the project interpreter or terminal.
  • Start by importing necessary Kivy modules: App, GridLayout, Label, TextInput, and Button.

Building the App Structure

  • Define a class (e.g., ChildApp) inheriting from GridLayout to construct the app's layout.
  • Set the number of columns in the layout (commonly 2 for label-input pairs).
  • Add Label and TextInput widgets for user data entry fields (e.g., student name, marks, gender).
  • Store references to TextInput widgets for later data retrieval.

Adding Interaction and Functionality

  • Add a Button widget labeled (e.g., "Click Me") to submit user input.
  • Bind the button’s on_press event to a function (e.g., click_me) for processing input.
  • In the function, retrieve text from input fields and print entered data to the terminal.

Running and Testing the Application

  • Define a parent class inheriting from App to launch the application (e.g., ParentApp).
  • Run the app by calling ParentApp().run() within the if __name__ == "__main__": block.
  • Test the app by entering values, pressing the button, and verifying data output in the terminal.

Key Terms & Definitions

  • Kivy β€” An open-source Python library for cross-platform app development.
  • App β€” The main application class in Kivy that manages app lifecycle.
  • GridLayout β€” A Kivy layout widget for arranging children in a grid of rows and columns.
  • Label β€” A widget for displaying text in Kivy.
  • TextInput β€” A widget allowing user text entry.
  • Button β€” A clickable widget to trigger actions in Kivy.
  • on_press β€” Event triggered when a button is pressed.

Action Items / Next Steps

  • Practice modifying the app to add or change input fields.
  • Explore the Kivy documentation for more advanced features.
  • Prepare for upcoming tutorials on more complex Python Kivy projects.