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
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
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.
- 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:
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.