Professional Documents
Culture Documents
To create a typing
speed test user
interface game
with Python
sachjith M
Class 12 pinnacle
COMPUTER SCIENCE
SYNOPSIS
DECLARATION
I, SACHJITH.M , of class
XII, hereby declare that the Project entitled “
TYPING SPEED TEST GUI WITH PYTHON ” submitted to
SUGUNA PIP SCHOOL: (Affiliation number – 1930213),
Nehru Nagar, Kalapatty Road, Coimbatore, Tamil Nadu –
641014. Regard to the class XII Senior Secondary
Examination for the CBSE Board, is accord of original
project work done by me under the guidance and supervision
of ALLPIOUS R, Faculty in Information technology
department, Suguna PIP School, further certify that
Name: Sachjith.M
2. Project Abstract
3. System requirements
6. Sample output
7. Conclusion
8. Bibliography
ACKNOWLEDGEMENT
Thank you : )
System Requirements
Processors:
Intel® Core™ i3 processor 4300M at 2.60
GHz.
Disk space: 2 to 4 GB.
Operating systems: Windows® 10,
MACOS, and UBUNTU.
Python Versions: 3.X.X or Higher.
Processors:
Intel Atom® processor or Intel® Core™
i3 processor.
Disk space: 1 GB.
Operating systems: Windows 7 or later,
MACOS, and UBUNTU.
Python Versions: 2.7.X, 3.6.X. (pygame)
Introduction about python and it’s
features
Features:
startingimage = 'bg.jpg'
backgroundimage = 'bg.jpg'
essay = 'essay.txt'
icon = 'icon.png'
import sys
import time
import random
import pygame
class Test:
def __init__(self):
self.color_heading = (255,213,102)
self.color_text = (255,0,0)
self.color_results = (255,70,70)
self.w=750
self.h=500
self.reset=True
self.wpm = 0
self.end = False
self.active = False
self.input_text=''
self.word = ''
self.start_time = 0
self.overall_time = 0
self.accuracy = '0%'
pygame.init()
self.image_open = pygame.image.load(startingimage)
self.image_open = pygame.transform.scale(self.image_open,
(self.w,self.h))
self.bg = pygame.image.load(backgroundimage)
self.screen = pygame.display.set_mode((self.w,self.h))
screen.blit(text, text_rect)
pygame.display.update()
def get_challenge(self):
return random.choice(open(essay).read().split('\n'))
if(not self.end):
count = 0
try:
if self.input_text[i] == c:
count = count + 1
except:
pass
self.accuracy = (count*100)/len(self.word)
#Calculate Words per Minute
self.wpm = (len(self.input_text)*60)/(5*self.overall_time)
self.end = True
print(self.overall_time)
self.time_img = pygame.image.load(icon)
self.time_img = pygame.transform.scale(self.time_img,
(150,150))
screen.blit(self.time_img, (self.w/2-75,self.h-140))
print(self.results)
pygame.display.update()
def run(self):
self.reset_game()
# it is running or not
self.running=True
while(self.running):
clock = pygame.time.Clock()
self.screen.fill((0,0,0), (50,250,650,50))
pygame.draw.rect(self.screen,self.color_heading,
(50,250,650,50), 2)
pygame.display.update()
if event.type == QUIT:
self.running = False
sys.exit()
x,y = pygame.mouse.get_pos()
self.active = True
self.input_text = ''
self.start_time = time.time()
self.reset_game()
x,y = pygame.mouse.get_pos()
if event.key == pygame.K_RETURN:
print(self.input_text)
self.results_show(self.screen)
print(self.results)
self.end = True
else:
try:
self.input_text += event.unicode
except:
pass
pygame.display.update()
# clock timer
clock.tick(60)
def reset_game(self):
self.screen.blit(self.image_open, (0,0))
pygame.display.update()
time.sleep(1)
self.reset=False
self.end = False
self.input_text=''
self.word = ''
self.start_time = 0
self.overall_time = 0
self.wpm = 0
self.word = self.get_challenge()
self.screen.fill((0,0,0))
self.screen.blit(self.bg,(0,0))
pygame.draw.rect(self.screen,(255,192,25), (50,250,650,50),
2)
pygame.display.update()
if __name__=='__main__':
Test().run()
bg.jpg
essay.txt
Icon.jpg
SAMPLE OUTPUT
CONCLUSION AND SCOPE OF
IMPROVEMENT
3. https://techvidvan.com/tutorials/project-in-
python-typing-speed-test/