Back to Browse

Tkinter GUI displaying real time clock with Weekday and date in different formats

7.5K views
Aug 25, 2021
14:17

We can display a clock showing change in time along with weekday and the date in a window by using Tkinter. To display this first we will take a blank window and then add one Label with bigger font style to this. We will create a function my_time() and inside this we will use config() to manage the text option of the Label. def my_time(): time_string = strftime('%H:%M:%S %p') # time format l1.config(text=time_string) l1.after(1000,my_time) # time delay of 1000 milliseconds Here we are using one time function after() to trigger the function again after 1000 milliseconds ( 1 second ). So this function will run every time in one second duration. The function strftime() produces the time in the given format. The list of format is available here List of date and time formats with source code is here %x, https://www.plus2net.com/python/tkinter-clock.php To display date in local format we can use On click of a button we can display the local time in one Entry widget. This trigger can be done by using Click of a button using command option. This option will trigger a function and the function will set the string variable connected to the Entry widget. #TkinterClock #tkitnerDisplayTime #timeinGUI #timewindow #displaytime #tkinter #python #plus2net #datetime #weekdayGUI #timeGUI

Download

0 formats

No download links available.

Tkinter GUI displaying real time clock with Weekday and date in different formats | NatokHD