Clock App with Kivy using Python Last Updated : 29 Nov, 2022 Comments Improve Suggest changes Like Article Like Report In this article, we are going to see how to develop a Clock Application with Kivy using Python. Kivy is a graphical user interface opensource Python library that allows you to develop multi-platform applications on Windows, macOS, Android, iOS, Linux, and Raspberry-Pi. In addition to the regular mouse and keyboard inputs, it also supports multitouch events. We will be using the time module to get the current time and update it every second. Moreover, we will be also be displaying two times of different timezones. Functions Usedasctime(): By default gets the local time. You can also pass the time zone in it to get the time of another zone as done in Example 2.BoxLayout(): It is used to arrange layouts in vertical or horizontal boxes.schedule_interval(): Is used to create time intervals and recall the function/event.add_widget(): Adds widget to the screen.Example 1: Local time app using kivy Python3 # importing modules # it will allow us to get time import time # The App class is the base for # creating Kivy applications from kivy.app import App # it will allow us to make interval calls from kivy.clock import Clock # Label widget will be used to render text from kivymd.uix.label import Label # we will be using this to resize app window from kivy.core.window import Window # it will allow us to create layouts from kivy.uix.boxlayout import BoxLayout # declaring window size Window.size = (400, 700) # clock class class myclock(Label): def update(self, *args): # get the current local time self.text = time.asctime() # App class class TimeApp(App): def build(self): layout = BoxLayout(orientation='vertical') # it will create vertical layouts in app # calling clock class for time clock1 = myclock() # updates time with the interval of 1 sec Clock.schedule_interval(clock1.update, 1) # adding layout to the screen layout.add_widget(clock1) # adding text to screen layout.add_widget(Label(text='INDIA')) return layout root = TimeApp() root.run() # running the app Output: Code Explanation The code starts with importing the modules that we need to use.The first module is time which will allow us to get the current local time.Next, it imports the Clock class which will be used for scheduling updates of myclock widget.It then creates a new app called TimeApp and builds it by adding a layout boxlayout and text label.The code is a sample of how to create an application with the Kivy framework.The first line imports modules that will allow us to get time and use it in our code.Line 3 declares the App class which is the base for creating Kivy applications.It allows us to make interval calls, add widgets, and return layouts.Line 4 creates a new instance of myclock widget which renders text.Line 5 schedules 1 second update intervals on clock1 by calling Clock.schedule_interval().Line 6 adds layout to screen with widgets added and returns layout as result of build() function call.Line 7 adds text to screen with Label widget added and returns layout as result of build() function call.Example 2: Adding another time zone in the time app Create another clock class and Add an extra layout for clock 2 in-app class. Python3 import time from kivy.app import App from kivy.clock import Clock from kivymd.uix.label import Label from kivy.core.window import Window from kivy.uix.boxlayout import BoxLayout Window.size = (400, 700) class myclock(Label): def update(self, *args): self.text = time.asctime() class myclock2(Label): def update(self, *args): t = time.gmtime() self.text = time.asctime(t) class TimeApp(App): def build(self): layout = BoxLayout(orientation='vertical') clock1 = myclock() Clock.schedule_interval(clock1.update, 1) layout.add_widget(clock1) layout.add_widget(Label(text='INDIA')) clock2 = myclock2() Clock.schedule_interval(clock2.update, 1) layout.add_widget(clock2) layout.add_widget(Label(text='LONDON')) return layout root = TimeApp() root.run() Output: Code Explanation: The code starts by creating two Label widgets.The first is myclock1 and the second is myclock2.They are both created with a function called update, which takes no arguments and returns nothing.This means that when they are updated, their text will be set to the current time in asctime().The next step is to create a BoxLayout widget with an orientation of 'vertical'.It then adds these two Label widgets to it.Finally, it creates another BoxLayout widget but this one has an orientation of 'horizontal' and adds those two Label widgets again.The code is designed to create a widget that displays the current time on screen.The first widget, myclock1, will update every second and display the current time in text form.The second widget, myclock2, will update every second and display the current time in text form with an extra line of text at the top displaying the difference between seconds (in this case 1). Comment More infoAdvertise with us Next Article Clock App with Kivy using Python vinamrayadav Follow Improve Article Tags : Python Geeks Premier League Geeks-Premier-League-2022 Python-kivy Practice Tags : python Similar Reads Python | Spinner widget 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 Desktops applications. 👉🏽 Kivy Tutorial - Learn Kivy with Examples. Spi 5 min read Create Analog Clock using PyQt5 in Python Prerequisite: Introduction to pyqt-5 A clock or watch is called "analog" when it has moving hands and (usually) hours marked from number 1 to 12 to show you the time. Some have Roman Numerals (I, II, III, etc) instead, or no numbers at all! In other words: not a digital clock. PyQt5 is a cross-platf 3 min read Python | Canvas in Kivy using .kv file 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. Kivy Tutorial - Learn Kivy with Examples. Canvas : The Canvas is 4 min read Python | Make a simple window using kivy Kivy is a platform independent as it can be run on Android, IOS, linux and Windows etc. Kivy provides you the functionality to write the code for once and run it on different platforms. It is basically used to develop the Android application, but it Does not mean that it can not be used on Desktops 5 min read Python | Popup widget in Kivy using .kv file 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. ?? Kivy Tutorial - Learn Kivy with Examples. Popup widget: To us 4 min read How to make calculator using kivy | Python 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. ???????? Kivy Tutorial - Learn Kivy with Examples. In this artic 3 min read Python | Checkbox widget in Kivy Kivy is a platform independent GUI tool in Python. Kivy applications 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. Kivy Tutorial - Learn Kivy with Examples. Checkbox 4 min read Python | Spinner widget in Kivy using .kv file 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. 👉🏽 Kivy Tutorial - Learn Kivy with Examples. Spi 3 min read 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 4 min read Python | Animation in Kivy using .kv file 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. Animation: Animation and AnimationTransition are used to anima 3 min read Like