Merge pull request #23 from ArshErgon/typing_test

Typing test
This commit is contained in:
Advaita Saha 2022-10-02 15:49:14 +05:30 committed by GitHub
commit ded17689de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 104 additions and 32 deletions

View File

@ -1,9 +0,0 @@
## Screen Shot CLI proudly made with Python
### Installation
```
$ pip install -i requirements.txt
$ python3 screen_shot.py
```
> change the sleep time if for you its take time to minimize the Terminal window. Images will be save inside the present folder

View File

@ -1,9 +0,0 @@
MouseInfo==0.1.3
PyAutoGUI==0.9.53
PyGetWindow==0.0.9
PyMsgBox==1.0.9
pyperclip==1.8.2
PyRect==0.2.0
PyScreeze==0.1.28
python3-xlib==0.15
pytweening==1.0.4

View File

@ -1,14 +0,0 @@
import pyautogui
from time import sleep
def screenshot_fun():
print("Screenshot program runs on console\nchange the sleep time if you can the screenshot captured the terminal also")
sleepTimer = 2
print(f"You've {sleepTimer} to minimize the terminal window")
sleep(sleepTimer)
print("Captured the screen now")
screenshot_img = pyautogui.screenshot()
screenshot_img.save("screen.png")
if __name__ == '__main__':
screenshot_fun()

View File

@ -0,0 +1,8 @@
## Typing Test Application proudly made with Python
> A program with which is made with Python, with the interface possible by Tkinter, a default GUI libray in python.
<img src="assets/imgOne.png" alt="broken Img" width="50%">
It uses a timer, which goes from 0 to 60, after the 60 hits you can see your word per mintue speed.
<img src="assets/imgTwo.png" alt="broken Img" width="50%">

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -0,0 +1,96 @@
from tkinter import *
import random
import tkinter
# main root
root = Tk()
root.title('Type Speed Test')
# the geometry of the window
root.geometry('700x700')
# Setting the Font for all Labels and Buttons
root.option_add("*Label.Font", "consolas 30")
root.option_add("*Button.Font", "consolas 30")
def keyPress(event=None):
try:
if event.char.lower() == labelRight.cget('text')[0].lower():
labelRight.configure(text=labelRight.cget('text')[1:])
labelLeft.configure(text=labelLeft.cget('text') + event.char.lower())
currentLetterLabel.configure(text=labelRight.cget('text')[0])
except tkinter.TclError:
pass
def resetWritingLabels():
# Text List
possibleTexts = [
'The fact that theres a stairway to heaven and a highway to hell explains life well. The Great Dane looked more like a horse than a dog. Barking dogs and screaming toddlers have the unique ability to turn friendly neighbors into cranky enemies. The sunblock was handed to the girl before practice, but the burned skin was proof she did not apply it. Fluffy pink unicorns are a popular status symbol among macho men. There was no telling what thoughts would come from the machine. She cried diamonds. He excelled at firing people nicely. Its never been my responsibility to glaze the donuts. Everyone pretends to like wheat until you mention barley. The body piercing didnt go exactly as he expected',
'She saw no irony asking me to change but wanting me to accept her for who she is. The quick brown fox jumps over the lazy dog. The blinking lights of the antenna tower came into focus just as I heard a loud snap. He decided to count all the sand on the beach as a hobby. Im not a party animal, but I do like animal parties. The gruff old man sat in the back of the bait shop grumbling to himself as he scooped out a handful of worms. He told us a very exciting adventure story. She was too busy always talking about what she wanted to do to actually do any of it. She was amazed by the large chunks of ice washing up on the beach. After coating myself in vegetable oil I found my success rate skyrocketed. You have no right to call yourself creative until you look at a trowel and think that it would make a great lockpick.',
'As always, we start with the imports. Because we make the UI with tkinter, we need to import it. We also import the font module from tkinter to change the fonts on our elements later. We continue by getting the partial function from functools, it is a genius function that excepts another function as a first argument and some args and kwargs and it will return a reference to this function with those arguments. This is especially useful when we want to insert one of our functions to a command argument of a button or a key binding.'
]
text = random.choice(possibleTexts).lower()
splitPoint = 0
global labelLeft
labelLeft = Label(root, text=text[0:splitPoint], fg='grey')
labelLeft.place(relx=0.5, rely=0.5, anchor=E)
global labelRight
labelRight = Label(root, text=text[splitPoint:])
labelRight.place(relx=0.5, rely=0.5, anchor=W)
global currentLetterLabel
currentLetterLabel = Label(root, text=text[splitPoint], fg='grey')
currentLetterLabel.place(relx=0.5, rely=0.6, anchor=N)
global timeleftLabel
timeleftLabel = Label(root, text=f'0 Seconds', fg='grey')
timeleftLabel.place(relx=0.5, rely=0.4, anchor=S)
global writeAble
writeAble = True
root.bind('<Key>', keyPress)
global passedSeconds
passedSeconds = 0
root.after(60000, stopTest)
root.after(1000, addSecond)
def stopTest():
global writeAble
writeAble = False
amountWords = len(labelLeft.cget('text').split(' '))
timeleftLabel.destroy()
currentLetterLabel.destroy()
labelRight.destroy()
labelLeft.destroy()
global ResultLabel
ResultLabel = Label(root, text=f'Words per Minute: {amountWords}', fg='black')
ResultLabel.place(relx=0.5, rely=0.4, anchor=CENTER)
global ResultButton
ResultButton = Button(root, text=f'Retry', command=restart)
ResultButton.place(relx=0.5, rely=0.6, anchor=CENTER)
def restart():
ResultLabel.destroy()
ResultButton.destroy()
resetWritingLabels()
def addSecond():
global passedSeconds
passedSeconds += 1
timeleftLabel.configure(text=f'{passedSeconds} Seconds')
if writeAble:
root.after(1000, addSecond)
resetWritingLabels()
root.mainloop()