Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson14_1
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a18416cd
authored
Mar 15, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
02faee63
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
0 deletions
fuxi.py
test1.py
fuxi.py
0 → 100644
View file @
a18416cd
#import turtle as t
from
turtle
import
*
from
time
import
*
#绘制指针的函数
def
drawPointers
():
#关闭慢动作,画笔跟踪函数,这个过程相当于可以看到慢动作,但是需要关闭掉,无需看见绘制过程
tracer
(
False
)
#重置指针,因为时分秒针已知处于不断变化之中,需要不断擦除,不断绘制新的
hour_pointer
.
reset
()
min_pointer
.
reset
()
sec_pointer
.
reset
()
#获取当前小时数
h
=
localtime
()
.
tm_hour
#获取当前分数
m
=
localtime
()
.
tm_min
#时针转动角度
hour_deg
=
-
360
/
(
12
*
60
)
*
(
60
*
h
+
m
)
+
90
#设置时针宽度为8
hour_pointer
.
width
(
8
)
hour_pointer
.
color
(
"white"
)
#转动度数
hour_pointer
.
setheading
(
hour_deg
)
#画出时针
hour_pointer
.
forward
(
60
)
hour_pointer
.
hideturtle
()
#设置分针
min_deg
=
-
6
*
m
+
90
#设置分针宽度为4
min_pointer
.
width
(
4
)
min_pointer
.
color
(
"white"
)
#转动度数
min_pointer
.
setheading
(
min_deg
)
#画出分针
min_pointer
.
forward
(
110
)
#设置秒针
s
=
localtime
()
.
tm_sec
sec_deg
=
-
6
*
s
+
90
#设置分针宽度为4
sec_pointer
.
width
(
2
)
sec_pointer
.
color
(
"white"
)
#转动度数
sec_pointer
.
setheading
(
sec_deg
)
#画出时针
sec_pointer
.
forward
(
140
)
tracer
(
True
)
#延迟执行,参数中函数名按照参数中的毫秒延迟执行,
# 为了达到重复执行的目的,可以把参数直接填入证字啊执行的函数中
ontimer
(
drawPointers
,
500
)
#主程序(多个海龟,对其中一个海龟设置,其他的不受影响)
hour_pointer
=
Turtle
()
min_pointer
=
Turtle
()
sec_pointer
=
Turtle
()
color
(
'black'
,
'blue'
)
goto
(
0
,
-
150
)
begin_fill
()
width
(
30
)
circle
(
150
)
end_fill
()
#表盘文字
color
(
'yellow'
)
penup
()
for
hour
in
[
12
,
3
,
6
,
9
]:
home
()
goto
(
0
,
-
9
)
setheading
(
-
hour
*
30
+
90
)
forward
(
148
)
write
(
str
(
hour
),
font
=
(
'Arial'
,
16
,
'normal'
))
hideturtle
()
#调用函数
drawPointers
()
done
()
test1.py
0 → 100644
View file @
a18416cd
import
turtle
p
=
turtle
.
Pen
()
p
.
setheading
(
90
)
p
.
forward
(
100
)
turtle
.
done
()
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment