猫史档案馆


WLYxfg发布=>能帮我查出错误吗?

用户:皓bdpG皓bdpG查看:0 回复:1 评论:0 创建时间:2020-11-17T21:45:35


我的指针没了

import turtle as t
import time

t.bgcolor("black")
t.setup(400,400)

t.pensize(3)
t.hideturtle()

s1 = t.Pen()
s1.pensize(3)
s1.hideturtle()

m1 = t.Pen()
m1.pensize(3)
m1.hideturtle()

h1 = t.Pen()
h1.pensize(3)
h1.hideturtle()

喵h1 = t.Pen()
喵h1.pensize(0)
喵h1.hideturtle()
喵h1.penup()
喵h1.pencolor('black')
#--------------------------------------------------------#1
def SetupClock():
    #基座
    t.pencolor('white')
    t.dot(300)
    #t.pencolor('black')
    t.penup()
    t.goto(0,-170)
    t.pendown()
    t.circle(170)
    #表盘
    t.pencolor('black')
    for i in range(60):
        t.seth(90+(i)*-6)
        t.penup()
        t.goto(0,0)
        if i % 5 == 0:
            t.forward(110)
            t.seth(-90)
            if i % 15 == 0:
                t.forward(15)
                t.write(i//5, align="center",font=("Courier", 18, "bold"))
                t.backward(15)
            else:
                t.forward(5)
                t.write(i//5, align="center",font=("Courier", 10, "bold"))
                t.backward(5)
            t.seth(90+(i)*-6)
            t.forward(20)
        else:
            t.forward(130+20/2)
        t.pendown()
        if i % 5 == 0:
            t.forward(20)
        else:
            t.forward(20/2)
#h:105,w:30

#--------------------------------------------------------#2
def checkTime(i):
    if (i < 10):
        i = "0" + str(i)
    else:
        i = str(i)
    return i

def dayTime():
    h = int(time.strftime('%H'))
    m = int(time.strftime('%M'))
    s = int(time.strftime('%S'))
    # add a zero in front of numbers<10
    h = checkTime(h)
    m = checkTime(m)
    s = checkTime(s)
    return h + ":" + m + ":" + s;

def yearTime():
    m,d,y = (time.strftime('%D').split('/'))
    y, m, d = str(time.strftime('%Y')),str(m), str(d)
    return y + '-' +m + '-' +d

def Week():
    week = ["星期一", "星期二", "星期三", "星期四", "星期五",
            "星期六", "星期日"]
    a = (int(time.strftime('%w'))-1)
    return week[a]  # 用星期的值作为下标选择列表值
#--------------------------------------------------------#3
def pen_s(du):
    s1.pencolor('red')
    s1.penup()
    s1.home()
    s1.seth(du)
    s1.clear()
    s1.pendown()
    s1.forward(90)
    
def pen_m(du):
    m1.pencolor('black')
    m1.penup()
    m1.home()
    m1.pendown()
    m1.seth(du)
    m1.clear()
    m1.pendown()
    m1.forward(70)
    
def pen_h(du):
    h1.pencolor('black')
    h1.penup()
    h1.home()
    h1.seth(du)
    h1.clear()
    h1.pendown()
    h1.forward(50)

def draw_Clock():
    h,m,s = dayTime().split(':')
    s = int(s)*-6+90
    m = int(m)*-6+90 + int(s)*-0.1
    h = int(h)*-30+90 + int(m)*-0.5 + int(s)*(-0.1/12)
    pen_s(s)
    pen_m(m)
    pen_h(h)

def write_Clock():
    喵h1.clear()
    喵h1.goto(0,50)
    喵h1.write(dayTime(), align="center", font=("Arial",15))
    喵h1.goto(0,-50)
    喵h1.write(Week(), align="center", font=("Arial",10))
    喵h1.goto(0,-75)
    喵h1.write(yearTime(), align="center", font=("Arial",12))

def drawClock():
    write_Clock()
    draw_Clock()
#--------------------------------------------------------#4
def main():
    t.tracer(False) # 不显示绘制的过程,直接显示绘制结果
    SetupClock()
    sz = -15 
    while True:
        sy = time.strftime('%S')
        if sz != sy:
            drawClock()
            sz = sy
    
    t.tracer(True)  # 显示绘制的过程

if __name__ == "__main__":
    main()


回复

上一页1 页 / 共 1下一页
皓bdpG皓bdpG

喵=s m

点赞0


评论