12/26/2023 0 Comments Typing the does not equal signThe lambda here is simply gratuitous: new_word = lambda: random.choice(random.choice((WORDS, WORDS))) Would it really be so hard to do: target = "start" Currently your code is: def if_equal_delete_and_take_other_phrase(ev): Really? You do the same thing with the text to copy. Instead of having a score variable, you store the score in the partial text value of the score displaying widget. This code makes me cringe: points = "Score: " + str(int(points.split(': ')) + 1) Your code uses text entry and display components as variables. and since it does not change, you think you've made a mistake. and when you're typing you are not really looking at the entry box, just the target word. You should add a re-selection of a new word until it is different, otherwise the experience is "odd" (the word stays the same but your entry widget clears. I ran it with python and python3, both worked fine.Īnother thing that came up is that it occasionally happens that the next word is the same as the previous word. You should add this to your script: typing_ground.focus_set() When I ran your code, it ran fine, but a usability problem is that the text entry box does not have focus, you have to click on it to make it have the active focus/cursor. I love seeing functionality like this packed so concisely. Root.bind('', if_equal_delete_and_take_other_phrase) If text_to_copy.cget("text") = typing_ground.get(): Points = tk.Label(root, text = "Score: 0", font=FONT)ĭef if_equal_delete_and_take_other_phrase(ev): Typing_ground = tk.Entry(root, font=FONT) Text_to_copy = tk.Label(root, text = "start", font=FONT) New_word = lambda: random.choice(random.choice((WORDS, WORDS))) Tested in Linux, Python 3.4 but should work in any version in any OS. The code has in memory the top 100 words as per the Pareto Principle and Zipf's Law, of these, the top 10 are more common than the rest. This script allows you to practice your typing skills, as soon as you finish typing a new word appears for a non-stop typing experience.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |