Ep 4/7 Adding

Опубликовано: 09 Июль 2026
на канале: SE CS Academy
6
2

In this playlist, I will demonstrate how to build a simple typing speed counter using just Python
code :
import tkinter as tk

root = tk.Tk()
root.title("Typing Speed counter")
root.geometry("500x500") # size of window
root.resizable(True,True)

text = tk.Text(root)
text.pack()

status = tk.Label(root,text="Char: 0 | Word: 0 | Speed: 0")
status.pack()

start_time = None
running = False

def count_speed(event):
global start_time, running
if not running:
start_time = time.time()
running=True

text.bind("KeyRelease",count_speed)

def update_counter():
text_typed = text.get("1.0","end-1c")
words = len(text_typed.split())
char = len(text_typed)
wpm=0 # wpm = words per minute
if running and start_time:
minutes = (time.time() - start_time)/60
if minutes 0:
wpm = round(words/minutes)
status.configure(text = f"Characters : {char} | Words : {words} | Speed : {wpm} WPM")
root.after(1000,update_counter)

update_counter()

root.mainloop() # closing of window