Kivy – Python Framework for Mobile App development

20 Aug, 2020
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
We will open PyCharm and Create a New Project and Name it as “Tutorial”(Project Name), we can Name as we want.We will Right click on “Tutorial”(Project Name) and create a new Directory Named as FirstApp.Inside this FirstApp We will create a Python file named as Main.To install Kivy follow:Goto File->Settings->Project:Tutorial(Project Name).Under Project: Tutorial(Project Name), Click on Project Interpreter.Then Click on ‘+’ Sign on top right and Search for Kivy you will see the following Screen:Installing Kivy DependenciesSimilarly Click on the following dependencies to install them :kivy-deps.anglekivy-deps.glewkivy-deps.gstreamerkivy-deps.sdl2Example 1 : Printing Welcome Message on Kivy App# import the modulesfrom kivy.app import Appfrom kivy.uix.label import Label  # defining the Base Class of our first Kivy Appclass 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 :Example 2 : Creating Login Screen# importing the modulesfrom kivy.app import Appfrom kivy.uix.gridlayout import GridLayoutfrom kivy.uix.label import Labelfrom 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 :My Personal Notes
arrow_drop_upSave
We will open PyCharm and Create a New Project and Name it as “Tutorial”(Project Name), we can Name as we want.
We will Right click on “Tutorial”(Project Name) and create a new Directory Named as FirstApp.
Inside this FirstApp We will create a Python file named as Main.
To install Kivy follow:Goto File->Settings->Project:Tutorial(Project Name).Under Project: Tutorial(Project Name), Click on Project Interpreter.Then Click on ‘+’ Sign on top right and Search for Kivy you will see the following Screen:Installing Kivy DependenciesSimilarly Click on the following dependencies to install them :kivy-deps.anglekivy-deps.glewkivy-deps.gstreamerkivy-deps.sdl2Example 1 : Printing Welcome Message on Kivy App# import the modulesfrom kivy.app import Appfrom kivy.uix.label import Label  # defining the Base Class of our first Kivy Appclass 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 :Example 2 : Creating Login Screen# importing the modulesfrom kivy.app import Appfrom kivy.uix.gridlayout import GridLayoutfrom kivy.uix.label import Labelfrom 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 :My Personal Notes
arrow_drop_upSave
To install Kivy follow:
Goto File->Settings->Project:Tutorial(Project Name).Under Project: Tutorial(Project Name), Click on Project Interpreter.Then Click on ‘+’ Sign on top right and Search for Kivy you will see the following Screen:
Goto File->Settings->Project:Tutorial(Project Name).
Under Project: Tutorial(Project Name), Click on Project Interpreter.
Then Click on ‘+’ Sign on top right and Search for Kivy you will see the following Screen:
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 modulesfrom kivy.app import Appfrom kivy.uix.label import Label  # defining the Base Class of our first Kivy Appclass 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 :
Example 2 : Creating Login Screen
# importing the modulesfrom kivy.app import Appfrom kivy.uix.gridlayout import GridLayoutfrom kivy.uix.label import Labelfrom 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 :
Python-kivy
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | Get unique values from a list
Python | datetime.timedelta() function