Python | Create a stopwatch Using Clock Object in kivy
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 Desktop applications.
In this, we are going to see how can we create a stopwatch using a label.
In the code, we will be creating just a counter using the label in which when you set the time in seconds it will start decreasing like a countdown and in the second we will do the same by using clock object.
- Kivy provides Clock objects.
- Clock objects can be made to call a function when a specified time period has elapsed.
- A clock object in Kivy can be configured to call a function upon every elapse of time duration or only once.
It is good to use kivy inbuilt module while working with clock:
from kivy.clock import Clock
Basic Approach: 1) import kivy 2) import kivyApp 3) import label 4) import Animation 5) Import clock 6) import kivy properties(only needed one) 7) Set minimum version(optional) 8) Create Label class 9) Create App class 10) return Layout/widget/Class(according to requirement) 11) Run an instance of the class
# Simple Approach:
Note: Countdown starts from 100 and ends on 0
# Now By using Clock Object:
Note: This starts from 0 and runs until you cut the window