def end_game(): """ Ends the game and prepares the results """ global ended # Need a new instance because this method is called in a # separate thread and can't use the old database connection # created in the previous instance of ManageDB() db = ManageDB() stats = get_stats(correct_words, wrong_words, total_words) db.save_data(stats) # Saves the data to the database db.view_records() print("\n") for key, value in stats.items(): print(" " + key.title(), value, sep=": ") webbrowser.open("results.html") ended = True
TypeSpeed is a simple program that measures your typing speed and keeps the records in a database, at the end of every typing test the database is updated and an HTML file is generated that displays the records. Type on! """ # Python imports import random import webbrowser from threading import Timer # Local imports from src.managedb import ManageDB db = ManageDB() ended = False def main(): """ Displays available menu options """ print(" Type Speed by Andri - github.com/aaanndri") print("\n") print(" 1. Play") print(" 2. View records") choice = int(input()) while choice not in range(1, 3): print("> Invalid input")