├── clock.png ├── app.py └── README.md /clock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kalebu/Digital-clock-in-Python/HEAD/clock.png -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | from time import strftime 2 | from tkinter import Label, Tk 3 | 4 | # ======= Configuring window ========= 5 | window = Tk() 6 | window.title("") 7 | window.geometry("200x80") 8 | window.configure(bg="green") # =======Background of the clock===== 9 | window.resizable(False, False) # =====setting a fixed window size ======= 10 | 11 | clock_label = Label( 12 | window, bg="black", fg="cyan", font=("Arial", 30, "bold"), relief="flat" 13 | ) 14 | clock_label.place(x=20, y=20) 15 | 16 | 17 | def update_label(): 18 | """ 19 | This function will update the clock 20 | 21 | every 80 milliseconds 22 | """ 23 | current_time = strftime("%H: %M: %S\n %d-%m-%Y ") 24 | clock_label.configure(text=current_time) 25 | clock_label.after(80, update_label) 26 | clock_label.pack(anchor="center") 27 | 28 | 29 | update_label() 30 | window.mainloop() 31 | 32 | # ==============The end by github.com/kalebu ========== 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Digital-clock-in-Python 2 | 3 | Intro 4 | ----- 5 | This is a code for a simple **digital clock** made in python 6 | with help of the **time** module and **Tkinter** library 7 | 8 | 9 | How to run 10 | --------- 11 | 12 | Firstly download or clone this repo and then move into the project folder as shown below; 13 | 14 | ```bash 15 | $-> git clone https://github.com/Kalebu/Digital-clock-in-Python 16 | $-> cd Digital-clock-in-Python 17 | $ Digital-clock-in-Python -> python app.py 18 | ``` 19 | 20 | Output 21 | -------- 22 | Once you run the code, it will render the output similar to what shown below; 23 | 24 | ![digital_clock](https://user-images.githubusercontent.com/77124662/130321144-3776737b-dc39-4914-b19b-081aed8906b8.PNG) 25 | 26 | 27 | 28 | This code is the continuation of a series of Python tutorial published 29 | on [my blog](kalebujordan.com), and the full article with code for can 30 | be found on [Make a Digital Clock](https://kalebujordan.com/how-to-make-a-digital-clock-in-python/) 31 | 32 | 33 | Give it a star :tada: 34 | -------------- 35 | Did you find this information useful, then give it a star 36 | 37 | 38 | Credits 39 | ----------- 40 | All the credits to [kalebu](github.com/kalebu) 41 | --------------------------------------------------------------------------------