Skip to content
Related Articles

Related Articles

Improve Article

Kivy – Python Framework for Mobile App development

  • Last Updated : 20 Aug, 2020
Geek Week

Kivy is a free and open-source Python library used for developing mobile applications and other multitouch application software with a Natural User Interface.

Installation

We can download the latest version of Kivy from here. After opening the link you can choose your Platform and follow the instructions specific for your platform.

Installation using PyCharm

  1. We will open PyCharm and Create a New Project and Name it as “Tutorial”(Project Name), we can Name as we want.
  2. We will Right click on “Tutorial”(Project Name) and create a new Directory Named as FirstApp.
  3. Inside this FirstApp We will create a Python file named as Main.

      To install Kivy follow:



      1. Goto File->Settings->Project:Tutorial(Project Name).
      2. Under Project: Tutorial(Project Name), Click on Project Interpreter.
      3. Then Click on ‘+’ Sign on top right and Search for Kivy you will see the following Screen:
        installing kivy

      Installing Kivy Dependencies

      Similarly Click on the following dependencies to install them :

      • kivy-deps.angle
      • kivy-deps.glew
      • kivy-deps.gstreamer
      • kivy-deps.sdl2

      Example 1 : Printing Welcome Message on Kivy App




      # import the modules
      from kivy.app import App
      from kivy.uix.label import Label
        
      # defining the Base Class of our first Kivy App
      class MyApp(App):
        
          def build(self):
        
              # initializing a Label with text ‘Hello World’ 
              and return its instance
              return Label(text = 'welcome to GeeksforGeeks')
        
        
      if __name__ == '__main__':
          # MyApp is initialized and its run() method called
          MyApp().run()

      Output :
      Printing Message on Kivy App

      Example 2 : Creating Login Screen




      # importing the modules
      from kivy.app import App
      from kivy.uix.gridlayout import GridLayout
      from kivy.uix.label import Label
      from kivy.uix.textinput import TextInput
        
      # this class is used as a Base for our 
      # Root Widget which is LoginScreen 
      class LoginScreen(GridLayout):
        
          # overriding the method __init__() so as to 
          # add widgets and to define their behavior
          def __init__(self, **kwargs):
              super(LoginScreen, self).__init__(**kwargs)
        
              # GridLayout managing its children in two columns 
              # and add a Label and a TextInput for the Email id and password
              self.cols = 2
              self.add_widget(Label(text = 'Email id'))
              self.username = TextInput(multiline = False)
              self.add_widget(self.username)
              self.add_widget(Label(text = 'password'))
              self.password = TextInput(password = True, multiline = False)
              self.add_widget(self.password)
        
      class MyApp(App):
          def build(self):
              return LoginScreen()
        
        
      if __name__ == '__main__':
        
          # MyApp is initialized and 
          # its run() method called
          MyApp().run()

      Output :
      login app

       Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

      To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course




      My Personal Notes arrow_drop_up
Recommended Articles
Page :