Kivy is a platform independent GUI tool in Python. As it can be run on Android, IOS, linux and Windows etc. It is basically used to develop the Android application, but it does not mean that it can not be used on Desktops applications.
In this article we will learn about how can we Add the Animation to a Floating Action button. To learn How to create it you must know about the Animation and Clock.
Animation : Animation and AnimationTransition are used to animate Widget properties. You must specify at least a property name and target value. To use an Animation, follow these steps:
- Setup an Animation object
- Use the Animation object on a Widget
To animate a Widget’s x or y position, simply specify the target x/y values where you want the widget positioned at the end of the animation:anim = Animation(x=100, y=100) anim.start(widget)
Clock: The Clock object allows you to schedule a function call in the future; once or repeatedly at specified intervals.
It is must to use kivy inbuilt module while working with Animation and clock –from kivy.animation import Animation from kivy.clock import Clock
Basic Approach: 1) import kivy 2) import kivyApp 3) import Boxlayout 4) import Animation 5) Import Clock 6) Set minimum version(optional) 7) create Layout class and Add(create) animation in it 8) create App class 9) Set up .kv file : 1) Add Floating Button Properties 2) Create Main Window 3) Add Float Button(don't forget to give id) 10) return Layout/widget/Class(according to requirement) 11) Run an instance of the class
Implementation of the Approach:
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.