CREATING A FLOATING ACTION BUTTON SPEED DIAL USING KIVYMD
Link Of Video On You Tube - https://youtu.be/z8y6_c55F20
Following are the steps that are required to create 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 MDFloatingActionButtonSpeedDial 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 MDFloatingActionButtonSpeedDial class
1. data - Text data of button in dictionary type. In data the key is the name of the icon and value is the text to be printed in front of the icon
Example :- data : {"language-python":"python"}
In this Example language-python is icon name and python is the text.
2. rotation_root_button - used to rotate the root button (Takes True or False)
3. hint_animation_text - used to open the text when the cursor goes upon it (Takes True or False)
4. label_text_color - to change the text color of hint text (Takes values in list format)
5. bg_hint_color : - To change the background color of hint text (Takes values in list format).
6. bg_color_stack_button - To change thhe background color of stack button(Takes values in list format).
7. bg_color_root_button - To change the background color of root button (Takes values in list format).
8. color_icon_stack_button - To change the color of icon of stack button (Takes values in list format).
9. color_icon_root_buton - To change the color icon of root button (Takes values in list format).
10. callback - to call a function when the button is pressed.
11. on_open - to call a function when the button is open
12. on_close - To call a funtion when the button is close
Following is the code of this program :-
1. Code of Python program (Save it by .py extension)
from kivymd.app import MDApp
class Myapp(MDApp):
def build(self):
return
def call(self, obj):
print("Stack button is pressed")
def open(self):
print("Button is open")
def close(self):
print("Button is closed")
Myapp().run()
2. Code of Kivy program (Save it by name Myapp.kv)
MDScreen :
MDFloatingActionButtonSpeedDial :
data : {"language-python":"python","language-cpp":"C++","language-php":"PHP"}
rotation_root_button : True
hint_animation : True
label_text_color : [1,0,0,1]
bg_hint_color : [0,1,0,1]
bg_color_stack_button : [0,1,0,1]
bg_color_root_button : [0,1,0,1]
color_icon_root_button : [0,0,1,1]
color_icon_stack_button : [0,0,1,1]
callback : app.call
on_open : app.open()
on_close : app.close()
Greeting here, well done for job your doing, some of us are grateful, I am Matovu Shafik doing my bachelors degree in computer science in Uganda at Mbarara University of Science and Technology and am grateful to know you and join you.
ReplyDeleteAm coming up with a deep learning final year project in python, CNN, TensorFlow for Face Recognition and wanted to use mobile as my user interaction platform.
Is it possible to use kivyMD for my UI so that I can run my project on different platforms say android, iOS, windows, Linux and others??
Thanks.