LoC Clock

My modifications to the clock
 avatar
unknown
python
3 years ago
1.4 kB
6
Indexable
import turtle
import datetime

screen = turtle.Screen()
screen.setup(900, 900)
screen.setworldcoordinates(-1000, -1000, 1000, 1000)
screen.tracer(False)

face = turtle.Turtle()
face.ht()

hand = turtle.Turtle()
hand.ht()

def draw_face():
    face.up()
    face.goto(0, -700)
    face.down()
    
    face.up()
    face.home()
    face.down()
    face.dot(10)
    
    face.pensize(4)
    face.color('MediumPurple4')
    face.fillcolor('MediumPurple1')
    face.begin_fill()
    face.lt(15)
    for i in range(12):
        face.lt(30)
        for i in range(12):
            face.fd(200)
            face.lt(30)
    face.end_fill()

    screen.update()

def draw_hands():
    time = datetime.datetime.now()
    h = time.hour
    m = time.minute
    s = time.second
    hand.clear()
    hand.color('lavender')

    # hour
    hand.pensize(5)
    hand.seth(90 - (h + (m / 60)) * 30)
    hand.fd(200)
    hand.up()
    hand.home()
    hand.down()

    # minute
    hand.pensize(3)
    hand.seth(90 - (m + (s / 60)) / 60 * 12 * 30)
    hand.fd(350)
    hand.up()
    hand.home()
    hand.down()

    # second
    hand.pensize(1)
    hand.seth(90 - s / 60 * 12 * 30)
    hand.fd(550)
    hand.up()
    hand.home()
    hand.down()

    screen.update()
    turtle.ontimer(draw_hands, 10)



draw_face()
draw_hands()
turtle.done()
Editor is loading...