Friday, December, 12, 2025

Today This Free Friday I am Working on a project on YouTube a WPM Typing Test.

import curses
from  curses import wrapper

def main(stdscr):
    curses.int_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK)
    curses.int_pair(2, curses.COLOR_RED, curses.COLOR_BLACK)
    curses.int_pair(3, curses.COLOR_WHITE, curses.COLOR_BLACK)

    stdscr.clear()
    stdscr.addstr("Hello world!")
    stdscr.refresh()
    stdscr.getkey()

wrapper(main)
  • This part of the code is to color the text the users type in game.
def start_screen(stdscr):
    stdscr.clear()
    stdscr.addstr("Welcome to the Speed Typing Test!")
    stdscr.addstr("\nPress any key to begin!")
    stdscr.refresh()
    stdscr.getkey()
  • This part of the code is the start screen in the Speed Typing Test game and to start game the user is ask to press any key to begin.
def wpm_test(stdscr):
    target_text = "Hello world this is some test text for this app!"
    current_text = []

    
    while True:
        key = stdscr.getkey()
        current_text.append(key)

        stdscr.clear()
        stdscr.addstr(target_text)
        stdscr.refresh()


        for char in current_text:
            stdscr.addstr(char, curses.color_pair(1))
            
        stdscr.refresh()
  • This part of the code is to ask the user to type something and colors the the text the users was ask to type.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top