from turtle import *
import time
from playsound import playsound


time.time()
t = Turtle()

wn = Screen()
wn.title('Simple Analog Clock')
wn.bgcolor("black")
wn.setup(600, 600)
t.speed(7)
t.pensize(3)
t.hideturtle()
wn.tracer(0)

def draw_clock(hr, min, sec, t):

    t.pencolor('green')
    t.up()
    t.goto(0, 210)
    t.setheading(180)
    t.down()
    t.circle(210)
    # Draw the clock marking for hand hours
    t.up()
    t.goto(0,0)
    t.setheading(90)
    for h in range(12):
        t.forward(190)
        t.down()
        t.forward(20)
        t.penup()
        t.goto(0,0)
        t.right(30)

    # Draw the clock marking for minute and second
    t.up()
    t.goto(0, 0)
    t.setheading(90)
    for m in range(60):
        t.forward(200)
        t.down()
        t.forward(10)
        t.penup()
        t.goto(0, 0)
        t.right(6)

    # Draw Number on Clock
    #One
    t.penup()
    t.goto(0,0)
    t.setheading(60)
    t.fd(145)
    t.setheading(0)
    t.fd(15)
    t.write(1, move=False, align="center", font=("arial",25,'normal'))

    # two
    t.penup()
    t.goto(0, 0)
    t.setheading(30)
    t.fd(135)
    t.setheading(0)
    t.fd(35)
    t.write(2, move=False, align="center", font=("arial", 25, 'normal'))

    # Three
    t.penup()
    t.goto(0, 0)
    t.setheading(352)
    t.fd(150)
    t.setheading(0)
    t.fd(25)
    t.write(3, move=False, align="center", font=("arial", 25, 'normal'))

    # Four
    t.penup()
    t.goto(0, 0)
    t.setheading(315)
    t.fd(150)
    t.setheading(0)
    t.fd(45)
    t.write(4, move=False, align="center", font=("arial", 25, 'normal'))

    # Five
    t.penup()
    t.goto(0, 0)
    t.setheading(290)
    t.fd(178)
    t.setheading(0)
    t.fd(25)
    t.write(5, move=False, align="center", font=("arial", 25, 'normal'))

    # Six
    t.penup()
    t.goto(0, 0)
    t.setheading(270)
    t.fd(190)
    t.write(6, move=False, align="center", font=("arial", 25, 'normal'))

    # Seven
    t.penup()
    t.goto(0, 0)
    t.setheading(258)
    t.fd(170)
    t.setheading(180)
    t.fd(48)
    t.write(7, move=False, align="center", font=("arial", 25, 'normal'))

    # Eight
    t.penup()
    t.goto(0, 0)
    t.setheading(228)
    t.fd(150)
    t.setheading(180)
    t.fd(45)
    t.write(8, move=False, align="center", font=("arial", 25, 'normal'))

    # Nine
    t.penup()
    t.goto(0, 0)
    t.setheading(188)
    t.fd(150)
    t.setheading(180)
    t.fd(25)
    t.write(9, move=False, align="center", font=("arial", 25, 'normal'))

    # Ten
    t.penup()
    t.goto(0, 0)
    t.setheading(150)
    t.fd(135)
    t.setheading(180)
    t.fd(25)
    t.write(10, move=False, align="center", font=("arial", 25, 'normal'))

    # Eleven
    t.penup()
    t.goto(0, 0)
    t.setheading(120)
    t.fd(145)
    t.setheading(180)
    t.fd(15)
    t.write(11, move=False, align="center", font=("arial", 25, 'normal'))

    # Twelve
    t.penup()
    t.goto(0, 0)
    t.setheading(90)
    t.fd(150)
    t.write(12, move=False, align="center", font=("arial", 25, 'normal'))
# -------------------------------------------------------------------------------
    # Draw Hour hand
    t.penup()
    t.goto(0, 0)
    t.pencolor('red')
    t.setheading(90)
    #print("Value of h in At the time of calculation", h)
    angleh = (hr/12) * 360
    #print("Angle for Hour",angleh)
    t.rt(angleh)
    t.down()
    t.fd(80)

    # Draw Minute hand
    t.penup()
    t.goto(0, 0)
    t.pencolor('blue')
    t.setheading(90)
    '''if m==59:
        playsound('malang.mp3')'''
    #print("Value of m in At the time of calculation", m)
    anglem = (min / 60) * 360
    #print("Angle for Minute", anglem)
    t.rt(anglem)
    t.down()
    t.fd(120)

    # Draw Second hand
    t.penup()
    t.goto(0, 0)
    t.pencolor('yellow')
    t.setheading(90)
   # print("Value of s in At the time of calculation", s)
    angles = (sec / 60) * 360
    #print("Angle for Second", angles)
    t.rt(angles)
    t.down()
    t.fd(160)

    # Designed By
    t.up()
    t.goto(0, 0)
    t.pencolor("red")
    t.setheading(268)
    t.fd(125)
    t.setheading(0)
    t.fd(5)
    t.write('DESIGNED BY MasS', move=False, align="center", font=("Viner Hand ITC", 15, 'bold'))

    # company name
    t.left(90)
    t.goto(0, 0)
    t.fd(100)
    t.write('ROLEX', move=False, align="center", font=("Viner Hand ITC", 15, 'bold'))




while True:
    h = int(time.strftime("%I"))
    m = int(time.strftime("%M"))
    s = int(time.strftime("%S"))
   # print('hour', h)
   # print('minute', m)
   # print('second', s)
    draw_clock(h, m, s, t)
    #time.sleep(3600)
    wn.update()
    time.sleep(1)
    t.clear()


mainloop()



