Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions TypeRacer/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"you get plant leaves, wrap them in paper, light it on fire and suck on it" which is normally a sentence-but not today because I'm setting out on the quest for a long sentence-that I'm typing up which reminds me of a story my grandpa told me about himself when he was "your age"-about how they covered the letters of the type writers and they had to type so-that they could memorize where the letters are on a type writer and my-grandpa says-he will never regret taking that class because it helped him out a lot when-it came to typing and now a days he is not bad a typing at all because He is almost-as fast as me because I am a pretty fast typer and writing this article isn't-taking very long and expect being pretty far pretty soon at-the pace I'm going right now so there are going to-be some serious records getting busted when I'm finally finished writing this article on-this dumb website which will probably end up huffing this article even though-it is fun-packed and joyful and keeps the reader reading when they use that excuse-mom saying "just one more sentence" but that sentence is 10,000 words long and still continuing to go at a reasonable pace
73 changes: 73 additions & 0 deletions TypeRacer/typeracer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from random import randint
import time
from io import *
def required_string():
f=open("test.txt","r+")
s=f.read()
l=[]
l=s.split("-")
x=randint(0,len(l)-1)
return l[x]
class Window(QWidget):
def __init__(self,parent=None):
QWidget.__init__(self,parent)
self.lt=QGridLayout()
self.l1=QLabel("")
self.pallet=QPalette()
self.s=required_string()
self.l1list=[]
self.l1list=self.s.split()
self.l1.setText(self.s)
self.inp=QLineEdit("")
self.countw=0
self.countcw=0
self.start=time.time()
self.pallet.setColor(QPalette.Foreground,Qt.green)
self.l1.setPalette(self.pallet)
self.inp.textChanged.connect(self.textchanged)
self.b1=QPushButton("Change paragraph")
self.b1.clicked.connect(self.pressed)
self.l2=QLabel("WPM:")
self.op=QLineEdit("")
self.lt.addWidget(self.l1,1,1,4,4)
self.lt.addWidget(self.inp,5,1,4,4)
self.lt.addWidget(self.l2,9,1,1,1)
self.lt.addWidget(self.op,9,2,1,1)
self.lt.addWidget(self.b1,9,4,1,1)
self.setLayout(self.lt)
def textchanged(self):
self.t=self.inp.text()
self.diff=(time.time()-self.start)
print(self.l1list[self.countw])
print(self.t)
if(self.t==self.l1list[self.countw]):
self.optextchange(1)
elif len(self.t)>1:
self.a=len(self.t)
if self.t[len(self.t)-1]=='\n' or self.t[len(self.t)-1]==' ':
self.countw=self.countw+1
self.inp.setText("")
self.optextchange(0)
def optextchange(self,a):
if a==1:
self.countcw=self.countcw+1
self.op.setText(str(self.countcw*60/self.diff))
def pressed(self):
self.s=required_string()
self.l1list=[]
self.l1list=self.s.split()
self.l1.setText(self.s)
self.start=time.time()
self.countcw=0
self.countw=0
def perform():
app=QApplication(sys.argv)
window=Window()
window.show()
sys.exit(app.exec())
if __name__=="__main__":
perform()