Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9ba71e6

Browse files
committed
refactored code and improved readme
1 parent bbf7925 commit 9ba71e6

File tree

2 files changed

+55
-10
lines changed

2 files changed

+55
-10
lines changed

‎README.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
11
# Digital-clock-in-Python
2-
A GUI version of **Digital clock** made in python
3-
using _Tkinter library_ in less than 15 lines of code
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;
423

524
![](clock.png?raw=true)
25+
26+
27+
This code is the continuation of a series of Python tutorial published
28+
on [my blog](kalebujordan.com), and the full article with code for can
29+
be found on [Make a Digital Clock](https://kalebujordan.com/how-to-make-a-digital-clock-in-python/)
30+
31+
32+
Give it a star
33+
--------------
34+
Did you find this information useful, then give it a star
35+
36+
37+
Credits
38+
-----------
39+
All the credits to [kalebu](github.com/kalebu)

‎app.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
11
from time import strftime
22
from tkinter import Label, Tk
33

4-
#======= Configuring window =========
4+
#======= Configuring window =========
55
window = Tk()
66
window.title("")
77
window.geometry("200x80")
8-
window.configure(bg="green")
9-
window.resizable(False, False)
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="green", fg="white", font=("Times", 30, "bold"), relief="flat"
13+
)
14+
clock_label.place(x=20, y=20)
1015

11-
clock_label = Label(window, bg="green", fg="white", font = ("Times", 30, 'bold'), relief='flat')
12-
clock_label.place(x = 20, y = 20)
1316

1417
def update_label():
15-
current_time = strftime('%H: %M: %S')
16-
clock_label.configure(text = current_time)
18+
"""
19+
This function will update the clock
20+
21+
every 80 milliseconds
22+
"""
23+
current_time = strftime("%H: %M: %S")
24+
clock_label.configure(text=current_time)
1725
clock_label.after(80, update_label)
1826

27+
1928
update_label()
20-
window.mainloop()
29+
window.mainloop()
30+
31+
# ==============The end by github.com/kalebu ==========

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /