forked from rakshith-git/speed_reader-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
67 lines (58 loc) · 1.43 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from turtle import*
import time
tracer(0)
delay = 0.05
f = open(r"reader.txt", "r")
# there is an automatic mode where the dealy is set by the length of the word
auto = False # make this true for auto mode
a = f.read().split() # makes a list of the text pasted
t = Turtle()
u = Turtle()
u.pu()
u.color('grey')
u.setpos(-200, 0) # turtle graphics stetting up things
t.ht()
u.ht()
i = 0
d = Turtle()
d.pu()
d.shape("turtle")
d.setpos(200, 0)
d.pd()
d.pensize(3)
d.lt(90)
d.fd(200)
d.bk(400)
d.fd(200)
d.pu()
d.shapesize(2, 2)
def rewind(): # rewinds by 30 words when space is pressed
global i
if i > 30:
i -= 30
time.sleep(0.2) # delay for user to know its rewinded
while i in range(0, len(a)):
# takes the y coordinate of the turtle on the right and changes delay accordingly
delay = 0.2-d.ycor() * 0.001
t.write(a[i], align="center", font=("Arial", 30, ("bold", "italic")))
u.write(round(60*(1/delay)), align="center",
font=("Arial", 30, ("bold", "italic")))
listen()
onkey(rewind, 'space')
if d.xcor != 200:
d.setx(200)
y = d.ycor()
if y > 200:
d.sety(200) # this part is the wpm adjusting
if y < -200:
d.sety(-200)
d.ondrag(d.goto)
if auto == True:
# dynamically changes delay word by word
time.sleep(delay+(0.015*len(a[i])))
if auto == False:
time.sleep(delay)
i += 1
t.clear()
u.clear()
update()