资源简介
实现虚拟的钟表,年月日,星期的展示
代码片段和文件信息
# -*- coding: utf-8 -*-
“““
Created on Fri Jul 31 16:52:53 2020
@author: dell
“““
# -*- coding:utf-8 –*-
# 用turtlr画时钟
# 以自定义shape的方式实现
import turtle as t
import datetime as d
def skip(step): # 抬笔,跳到一个地方
t.penup()
t.forward(step)
t.pendown()
def drawClock(radius): # 画表盘
t.speed(0)
t.mode(“logo“) # 以Logo坐标、角度方式
t.hideturtle()
t.pensize(7)
t.home() # 回到圆点
for j in range(60):
skip(radius)
if (j % 5 == 0):
t.forward(20)
skip(-radius - 20)
else:
t.dot(5)
skip(-radius)
t.right(6)
def makePoint(pointName len): # 钟的指针,时针、分针、秒针
t.penup()
t.home()
t.begin_poly()
t.back(0.1 * len)
t.forward(len * 1.1)
t.end_poly()
poly = t.get_poly()
t.register_shape(pointName poly) # 注册为一个shape
def drawPoint(): # 画指针
global hourPoint minPoint secPoint fontWriter
makePoint(“hourPoint“ 100)
makePoint(
- 上一篇:python推箱子 游戏素材
- 下一篇:snap7连接PLC
评论
共有 条评论