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
To change MDFloatingActionButton background, use the md_bg_color parameter:
The length of the shadow is controlled by the elevation_normal parameter:
To change the text colour of class MDFlatButton use the text_color parameter:
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:
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!