The import turtle
The from turtle import *
The from datetime import *
Def Skip (step) :
Penup ()
Forward (step)
Pendown ()
Def mkHand (name, length) :
Whose hands Turtle # registered Turtle shape, set up
Reset () # to empty the current window, and reset location and other information as the default value is
The Skip (- length * 0.1)
Begin_poly ()
Forward (length * 1.1)
End_poly ()
HandForm=get_poly ()
Register_shape (name, handForm)
Def Init () :
Global secHand, minHand hurHand, printer
Mode (" logo ") # reset Turtle pointing north
Whose hands Turtle # to establish three and initialize
MkHand (" secHand ", 250)
MkHand (" minHand ", 190)
MkHand (" hurHand ", 120)
SecHand=Turtle ()
SecHand. Shape (" secHand ")
MinHand=Turtle ()
MinHand. Shape (" minHand ")
HurHand=Turtle ()
HurHand. Shape (" hurHand ")
For hand in secHand, minHand hurHand:
Hand. Shapesize (1, 1, 3)
Hand. Speed (0)
# set up output text Turtle
Printer=Turtle ()
Printer. Hideturtle ()
Printer. Penup ()
Def SetupClock (radius) :
Frame # building tables
The reset ()
Pensize (7)
For I in range (60) :
The Skip (radius)
If I % 5==0:
Forward (18)
The Skip (radius - 18)
The else:
The dot (5)
The Skip radius, (-)
Right (6)
Def Week (t) :
Monday week=[", "" Tuesday", "on Wednesday,"
"Thursday", "Friday", "Saturday", "Sunday"]
Return week [t.w eekday ()]
Def Date (t) :
Y=t.y Lin ear
M=t.m onth
D=t.d ay
Return "% s % d % d % (y, m, d)
Def Tick () :
The dynamic display of the # draw something
T=a datetime. Today ()
Second=t.s econd + t.m icrosecond * 0.000001
Second minute=t.m inute +/60.0
Our + minute/hour=, Todd Harper 60.0
SecHand. Setheading (6 * second) # set toward, rotation 6 degrees per second
MinHand. Setheading (6 * minute)
HurHand. Setheading (30 * hour)
Tracer (False) # does not display the drawing process, direct mapping results shown
Printer. Forward (65)
Printer. Write (Week (t), the align="center",
The font=(" Courier ", 24,))
Printer. The back (130)
Printer. Write (Date (t), the align="center",
The font=(" Courier ", 30,))
Printer. The back (50)
Printer. Write (" Gino "align=" center ",
The font=(" Simyou ", 18,))
Printer. Home ()
Tracer (True)
Ontimer (1000) Tick, Tick # 1000 ms after continue to call
Def the main () :
Turtle. Color (" red ")
Tracer (False) # enables multiple drawn objects at the same time show
The Init ()
SetupClock (300)
Tracer (True)
Tick ()
Mainloop ()
If __name__=="__main__" :
The main ()
# how to put the clock into color?
# for great spirit consult!