forked from seeditsolution/pythonprogram
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypingSpeedMaster
More file actions
104 lines (85 loc) · 3.27 KB
/
Copy pathtypingSpeedMaster
File metadata and controls
104 lines (85 loc) · 3.27 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
words=['mango','apple','gun','elephant','laptop','favourite','automobile','decision','message','configure','rajat','time',
'python','navigate','typing','window','process','computer','scripts','global','structure','success','business','input','user','package','slider']
def labelSlider():
global count,sliderwords
text='Welcome to typing Speed Increaser Game'
if(count>= len(text)):
count = 0
sliderwords = ''
sliderwords += text[count]
count += 1
fontLabel.configure(text=sliderwords)
fontLabel.after(100,labelSlider)
def time():
global timeleft,score,miss
if(timeleft>11):
pass
else:
timeLabelCount.configure(fg='red')
if(timeleft>0):
timeleft -= 1
timeLabelCount.configure(text=timeleft)
timeLabelCount.after(1000,time)
else:
gameplayDetailLabel.configure(text='Hit={}| Miss = {} | Total Score = {}'.format(score,miss,score-miss))
rr=messagebox.askretrycancel('Notification','For Play Again Hit Retry Button ')
if(rr==True):
score = 0
timeleft = 60
miss = 0
timeLabelCount.configure(text=timeleft)
wordLabel.configure(text=words[0])
scoreLabelCount.configure(text=score)
def startGame(event):
global score,miss
if(timeleft==60):
time()
gameplayDetailLabel.configure(text='')
if(wordEntry.get()==wordLabel['text']):
score +=1
scoreLabelCount.configure(text=score)
else:
miss += 1
random.shuffle(words)
wordLabel.configure(text=words[0])
wordEntry.delete(0,END)
from tkinter import *
import random
from tkinter import messagebox
root= Tk()
root.geometry('800x600+400+100')
root.configure(bg='powder blue')
root.title('Typing Speed Increser Game')
root.iconbitmap('sr.ico')
######################################################variables
score=0
timeleft = 60
count = 0
sliderwords = ''
miss = 0
######################################################Label Method
fontLabel = Label(root,text='',font=('arial',25,'italic bold'),
bg='powder blue',fg='red',width=42)
fontLabel.place(x=10,y=10)
labelSlider()
random.shuffle(words)
wordLabel= Label(root,text=words[0],font=('arial',40,'italic bold'),bg='powder blue')
wordLabel.place(x=350,y=200)
scoreLabel = Label(root,text='Your Score :',font=('arial',25,'italic bold'),bg='powder blue')
scoreLabel.place(x=10,y=100)
scoreLabelCount = Label(root,text= score,font=('arial',25,'italic bold'),bg='powder blue',fg='blue')
scoreLabelCount.place(x=80,y=165)
timerLabel = Label(root,text='Time Left :',font=('arial',25,'italic bold'),bg='powder blue')
timerLabel.place(x=600,y=100)
timeLabelCount = Label(root,text= timeleft,font=('arial',25,'italic bold'),bg='powder blue',fg='blue')
timeLabelCount.place(x=680,y=165)
gameplayDetailLabel = Label(root,text='Type Word And Hit Enter Button',font=('arial',30,'italic bold'),
bg='powder blue',fg='dark grey')
gameplayDetailLabel.place(x=120,y=450)
################################################Entry Method
wordEntry = Entry(root,font=('arial',25,'italic bold'),bd=10,justify='center')
wordEntry.place(x=250,y=300)
wordEntry.focus_set()
##############################################
root.bind('<Return>',startGame)
root.mainloop()