Creating your first application using Kivy

10 Dec, 2021
Prerequisites: Introduction to Kivy, Hello World in Kivy
Kivymd is graphical user interface library in python based on kivy that allows you to develop multi-platform applications on Windows, MacOS, Android, iOS, Linux, and Raspberry Pi. The best thing about kivy is, it performs better than HTML5 cross-platform alternatives. Kivymd requires fewer lines of code compare to kivy. Kivymd is written in python using the kivy library.
In order to start KivyMD, you must first install the Kivy framework on your computer. Once you have installed Kivy, you can install KivyMD.
pip install kivymd
If you want to install the development version from the master branch, you should specify a link to zip archive:
pip install https://github.com/kivymd/KivyMD/archive/master.zip
MDFloatingActionButton: 
To change MDFloatingActionButton background, use the md_bg_color parameter:
MDFloatingActionButton:
   icon: "android"
   md_bg_color: app.theme_cls.primary_color
The length of the shadow is controlled by the elevation_normal parameter:
MDFloatingActionButton:
    icon: "android"
    elevation_normal: 12
MDFlatButton:
To change the text colour of class MDFlatButton use the text_color parameter:
MDFlatButton:
   text: "MDFLATBUTTON"
   text_color: 0, 0, 1, 1
There are three steps of creating an application with kivymd-
Inherit Kivymd’s App class which represents the window for our widgets
Create build() method, which will show the content of the widgets.
And at last calling of run() method.
Code blocks:
text: the text you want to show on screen.
halign: alignment of that text.
pos_hint: position from the text from the left and top (center_x =0.5 and center_y=0.5 represents the centre. of the screen).
icon: The type of icon you have to give for your button.
Below is the example of how we can create a simple application using kivy:
Python3
# import required modulesfrom kivymd.app import MDAppfrom kivymd.uix.button import MDFloatingActionButton, MDFlatButtonfrom kivymd.uix.screen import Screenfrom kivymd.icon_definitions import md_icons  class DemoApp(MDApp):    def build(self):                 # create screen object        screen = Screen()                 # create buttons        btn1 = MDFlatButton(text='Hello GFG', pos_hint={'center_x': 0.5,                                                        'center_y': 0.8})        btn = MDFloatingActionButton(icon="android",                                     pos_hint={'center_x': 0.5,                                               'center_y': 0.5},                                     )                 # add buttons        screen.add_widget(btn1)        screen.add_widget(btn)                 return screen        # run applicationDemoApp().run()
Output:
rkbhola5
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 | os.path.join() method
Python OOPs Concepts
How to drop one or multiple columns in Pandas Dataframe
Introduction To PYTHON
How To Convert Python Dictionary To JSON?
Check if element exists in list in Python
Python | datetime.timedelta() function
Python | Get unique values from a list