Skip to main content

MDRoundFlatButton

CREATING A ROUND FLAT BUTTON USING KIVYMD  





Video Link On YouTube - https://youtu.be/dgGAWPuf8hk

Following are the steps that are required to create Round Flat button :

  



1. Creating the App by importing the MDApp class of kivymd module.
2. Creating the Screen by using MDScreen class of kivymd module.
3. Creating a button using MDRoundFlatButton class of kivymd module. 

First Create a Python file (extension .py) then, create a kivy file (.kv extension) name of kivy file should be same as app name.

App name is the name of the class that consist of build function and created by inheriting the MDApp class

Following is the list of attributes used in this program :-

Attributes of MDScreen class
1. md_bg_color - To change the background color 
2. radius - to change the corner radius of screen

Attributes of MDRoundFlatButton class
1. text - Text to be printed in the button (takes string)
2. pos_hint -  To place the button at particular position (takes float values)
3. theme_text_color : To change the color of icon (Values Primary, Secondary, Hint, Error and Custom)

Note : When the value of theme_text_color is Custom then we can use text_color attribute to change the color.

4. text_color - To change the color of icon (Takes color values in rgb fromat)
5. elevation - To make shadow of button (takes numeric value)
6. font_size - To increase font size of button (takes numeric value) 
9. size_hint_y - To change the size of button takes float type values or None
10. height - To change the height of Button (Takes Numeric value)
11. on_press - Action to be performed when button is pressed
12.on_release - Action to be performed when the button is released

Following is the code of this program :-

# Code of Python File

from kivymd.app import MDApp

class Myapp(MDApp):
    def build(self):
        return
    # Defining the function
    def callback(self):
        print("Button is pressed")

Myapp().run()

# Save it by .py extension

# Code of Kivy File

MDScreen :
    MDRoundFlatButton :
        text : "MDRoundFlatButton"
        pos_hint : {"center_x":.5,"center_y":.5}
        font_size : 40
        size_hint_y : None
        height : 50
        theme_text_color : "Custom"
        text_color : [0,1,1,1]
        on_release : app.callback()

# Save it by name Myapp.kv


Comments