📜  数字时钟的turtule代码 - Python代码示例

📅  最后修改于: 2022-03-11 14:46:22.690000             🧑  作者: Mango

代码示例1
from turtle import *
import turtle

scr = turtle.Screen()
 
scr.setup(500, 500)

clock = turtle.Turtle()
 
clock.color('cyan')
 
clock.width(5)
 
 
def drawhourhand():
    clock.penup()
    clock.home()
    clock.right(90)
    clock.pendown()
    clock.forward(100)
 

val = 0
 
for i in range(12):
   
    val += 1
 
    clock.penup()
 
     clock.setheading(-30 * (i + 3) + 75)
 
    clock.forward(22)

    clock.pendown()
 
    clock.forward(15)
 
    clock.penup()
 
    clock.forward(20)
 
    clock.write(str(val), align="center",
              font=("Arial",
                    12, "normal"))
clock.setpos(2, -112)
clock.pendown()
clock.width(2)

clock.fillcolor('Green')
 
clock.begin_fill()
 
clock.circle(7)
 
clock.end_fill()
 
clock.penup()
drawhourhand()
clock.setpos(-18, -62)
clock.pendown()
clock.penup()
 
clock.setpos(-28, -150)
clock.pendown()
clock.write('Python Guides', font=("Arial",14,
                              "normal"))
clock.hideturtle()
turtle.done()