This repository was archived by the owner on Dec 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclock.py
More file actions
81 lines (64 loc) · 1.36 KB
/
clock.py
File metadata and controls
81 lines (64 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import turtle
import time
wn = turtle.Screen()
wn.bgcolor("black")
wn.setup(width=600, height=600)
wn.title("A Clock Made by @Philskillz")
wn.tracer(0)
pen = turtle.Turtle()
pen.hideturtle()
pen.speed(0)
pen.pensize(3)
def draw_clock(h, m, s, pen):
pen.up()
pen.goto(0, 210)
pen.setheading(180)
pen.color("green")
pen.pendown()
pen.circle(210)
pen.penup()
pen.goto(0, 0)
pen.setheading(90)
for _ in range(12):
pen.fd(190)
pen.pendown()
pen.fd(20)
pen.penup()
pen.goto(0, 0)
pen.rt(30)
#hours
pen.penup()
pen.goto(0, 0)
pen.color("white")
pen.setheading(90)
angle = (h / 12) * 360
pen.rt(angle)
pen.pendown()
pen.fd(100)
#minutes
pen.penup()
pen.goto(0, 0)
pen.color("blue")
pen.setheading(90)
angle = (m / 60) * 360
pen.rt(angle)
pen.pendown()
pen.fd(180)
#seconds
pen.penup()
pen.goto(0, 0)
pen.color("red")
pen.setheading(90)
angle = (s / 60) * 360
pen.rt(angle)
pen.pendown()
pen.fd(140)
while True:
h = int(time.strftime("%I"))
m = int(time.strftime("%M"))
s = int(time.strftime("%S"))
draw_clock(h, m, s, pen)
wn.update()
time.sleep(1)
pen.clear()
wn.mainloop()