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
c1d6b007
authored
Mar 26, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
9665e609
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
150 deletions
clock.py
erji.py
test111.py
clock.py
View file @
c1d6b007
...
...
@@ -20,23 +20,8 @@ reset()
#正常的度数应该是:度数 = Hour*(-30) ? 度数 = Hour*(-30) +90
#注意表的0小时可不是0度,而是海龟的90度
from turtle import *
color('#ffa500','#ffbb00')
goto(0,-150)
begin_fill()
width(30)
circle(150)
end_fill()
color('#FFF')
penup()
for hour in [12,3,6,9]:
home()
goto(0,-9)
setheading(hour*(-30) +90)
forward(148)
write(str(hour),font = ('Arial',18,'normal'))
#小时指针
...
...
@@ -48,106 +33,27 @@ for hour in [12,3,6,9]:
from time import *
#画出当前小时指针代码
h = localtime().tm_hour #获取当前小时数
m = localtime().tm_min #获取当前分钟数
hour_deg = -(360/(12*60))*(h*60+m) + 90 #时针转动角度
hour_pointer = Turtle() #创建一个海龟
hour_pointer.width(8)
hour_pointer.color('white')
hour_pointer.setheading(hour_deg)
hour_pointer.fd(60)
#分钟指针
#与小时类似
#假设现在是h小时m分钟,分针转一圈是60分钟360度 1分钟就是360/60=6度,现在m分钟应该是m*6度。
#分针的度数计算应该是-6m+90
min_deg = -6*m+90
min_pointer = Turtle()
min_pointer.width(4)
min_pointer.color("white")
min_pointer.setheading(min_deg)
min_pointer.fd(110) #画出分针
#秒针指针
s = localtime().tm_sec
sec_deg = -6*s + 90
sec_pointer = Turtle()
sec_pointer.width(2)
sec_pointer.color("white")
sec_pointer.setheading(sec_deg)
sec_pointer.fd(140)
'''
from
turtle
import
*
from
time
import
*
def
drawPointers
():
tracer
(
False
)
hour_pointer
.
reset
()
min_pointer
.
reset
()
sec_pointer
.
reset
()
#画出当前小时指针代码
h
=
localtime
()
.
tm_hour
#获取当前小时数(0-23)
m
=
localtime
()
.
tm_min
#获取当前分钟数(0-59)
hour_deg
=
-
(
360
/
(
12
*
60
))
*
(
h
*
60
+
m
)
+
90
#时针转动角度
hour_pointer
.
width
(
8
)
hour_pointer
.
color
(
'white'
)
hour_pointer
.
setheading
(
hour_deg
)
hour_pointer
.
fd
(
60
)
# hour_pointer.hideturtle()
#分针的度数计算应该是-6m+90
min_deg
=
-
6
*
m
+
90
min_pointer
.
width
(
4
)
min_pointer
.
color
(
"white"
)
min_pointer
.
setheading
(
min_deg
)
min_pointer
.
fd
(
110
)
#画出分针
s
=
localtime
()
.
tm_sec
sec_deg
=
-
6
*
s
+
90
sec_pointer
.
width
(
2
)
sec_pointer
.
color
(
"white"
)
sec_pointer
.
setheading
(
sec_deg
)
sec_pointer
.
fd
(
140
)
tracer
(
True
)
ontimer
(
drawPointers
,
500
)
hour_pointer
=
Turtle
()
min_pointer
=
Turtle
()
sec_pointer
=
Turtle
()
color
(
'#ffa500'
,
'#ffbb00'
)
goto
(
0
,
-
150
)
begin_fill
()
width
(
30
)
circle
(
150
)
end_fill
()
color
(
'#FFF'
)
penup
()
for
hour
in
[
12
,
3
,
6
,
9
]:
home
()
goto
(
0
,
-
9
)
setheading
(
hour
*
(
-
30
)
+
90
)
forward
(
148
)
write
(
str
(
hour
),
'center'
,
font
=
(
'Arial'
,
18
,
'normal'
))
hideturtle
()
drawPointers
()
done
()
#秒针指针
'''
...
...
erji.py
deleted
100644 → 0
View file @
9665e609
class
shopping
:
def
__init__
(
self
,
name
,
money
):
self
.
name
=
name
self
.
money
=
money
self
.
pen
=
0
def
buy
(
self
):
while
self
.
money
>
10
:
self
.
money
=
self
.
money
-
7
self
.
pen
=
self
.
pen
+
1
return
self
.
money
n
=
int
(
input
())
a
=
shopping
(
'Xiaoming'
,
n
)
print
(
a
.
buy
())
test111.py
View file @
c1d6b007
'''
#导入的方式
import turtle
from turtle import *
#时钟
#关闭慢动作,画笔跟踪函数,这个过程相当于可以看到慢动作,但是需要关闭掉,无需看见绘制过程
#画笔跟踪函数tracer()
# tracer(False)
#延迟执行 ontimer(函数名,毫秒)
#绘画的静态的,但是中间间隔的时间较短,所以看起来实际动态的。
...
...
@@ -34,25 +34,11 @@ reset()
#小时指针转一圈是12小时,1小时60分钟,360就是12*60 1分钟就是360/(12*60)
#那么一共过去了h*60+m分钟,就应该是 (360/(12*60))*(h*60+m)
#因为符号表示顺时针,有时从0时开始,所以度数应该为 -(360/(12*60))*(h*60+m) + 90
from turtle import *
color('#ffa500','#ffbb00')
goto(0,-150)
begin_fill()
width(30)
circle(150)
end_fill()
#绘制时钟数字
color('#FFF')
penup()
for hour in [12,3,6,9]:
#goto(0,0)
home()
goto(0,-9)
setheading(hour*(-30)+90)
forward(148)
write(str(hour),font=('Arial',18,'normal'))
...
...
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