-
Notifications
You must be signed in to change notification settings - Fork 0
/
Leons_Typewriter_multi.py
3960 lines (3642 loc) · 223 KB
/
Leons_Typewriter_multi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from words import english_words_full , english_words_essential , english_words_advanced
import tkinter as tk
from tkinter import messagebox , ttk
from PIL import Image, ImageTk
import random
import getpass
import webbrowser
import sqlite3
import platform
import subprocess
import datetime
os_name = platform.system()
if os_name == "Windows":
import ctypes
# Copyright (C) 2023 Mohammad Dorri https://www.github.com/PG6AW
positive_points = 0
negative_points = 0
total_keystrokes = 0
all_keypress = 0
correct_keystrokes = 0
number_of_words = 0
correct_words = 0
incorrect_words = 0
realtime_stroke_aggregator = 0
meter_timer = 0
wpm_calc = 0
keyboard_keys_used = []
total_stat = "On"
random_state = "0"
color_reset = "yes"
typewriter_mode = "Multi-Words"
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
conn = sqlite3.connect("accounts.db")
cursor = conn.cursor()
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
cursor.execute("""CREATE TABLE IF NOT EXISTS login_logs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
username TEXT,
email TEXT,
os_name TEXT,
event_by_admin TEXT,
login_date TEXT
)
""")
conn.commit()
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
event_by_admin = getpass.getuser()
the_user = "*N-U-L-L*"
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
try:
conn2 = sqlite3.connect("accounts.db")
cursor2 = conn2.cursor()
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
cursor2.execute("SELECT id FROM login_logs WHERE event_by_admin=?", (event_by_admin,))
Ids = cursor2.fetchall()
if Ids is None:
Ids = str(Ids)
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
ids = max(Ids)
for Id in ids:
Id = int(Id)
cursor2.execute("SELECT username FROM login_logs WHERE id=?", (Id,))
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
user_name = cursor2.fetchone()
if user_name is None:
user_name = str(user_name)
else:
for the_user in user_name:
the_user = str(the_user)
conn2.close()
except (sqlite3.OperationalError , ValueError , sqlite3.ProgrammingError):
pass
if the_user == "LOGGED->OUT" or the_user == "*N-U-L-L*":
conn.close()
subprocess.Popen(['python', 'login.py'])
retry = True
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
while retry:
retry = messagebox.askretrycancel("LOGGED OUT!", "You are currently Logged Out!\n\nYOU MUST LOG-IN FIRST BEFORE YOU COME BACK & RETRY!")
if retry:
conn2 = sqlite3.connect("accounts.db")
cursor2 = conn2.cursor()
cursor2.execute("""CREATE TABLE IF NOT EXISTS retry_cache (cache TEXT)""")
conn2.commit()
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
cursor2.execute("INSERT INTO retry_cache (cache) VALUES(?)", ("retried",))
conn2.commit()
conn2.close()
try:
conn2 = sqlite3.connect("accounts.db")
cursor2 = conn2.cursor()
cursor2.execute("SELECT id FROM login_logs WHERE event_by_admin=?", (event_by_admin,))
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
Ids = cursor2.fetchall()
if Ids is None:
Ids = str(Ids)
ids = max(Ids)
for Id in ids:
Id = int(Id)
cursor2.execute("SELECT username FROM login_logs WHERE id=?", (Id,))
user_name = cursor2.fetchone()
if user_name is None:
user_name = str(user_name)
else:
for the_user in user_name:
the_user = str(the_user)
conn2.close()
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
except (sqlite3.OperationalError , ValueError , sqlite3.ProgrammingError):
pass
if the_user != "LOGGED->OUT" and the_user != "*N-U-L-L*":
retry = False
subprocess.Popen(['python', 'Leons_Typewriter_multi.py'])
else:
conn2 = sqlite3.connect("accounts.db")
cursor2 = conn2.cursor()
cursor2.execute("""CREATE TABLE IF NOT EXISTS retry_cache (cache TEXT)""")
conn2.commit()
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
cursor2.execute("DELETE FROM retry_cache")
conn2.commit()
conn2.close()
exit()
else:
pass
conn3 = sqlite3.connect("typewriter.db")
cursor3 = conn3.cursor()
cursor3.execute("""CREATE TABLE IF NOT EXISTS records (
record_id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT,
total_score INTEGER,
net_wpm TEXT,
gross_wpm TEXT,
pure_wpm TEXT,
accuracy TEXT,
correct_chars INTEGER,
total_keystrokes INTEGER,
correct_keystrokes INTEGER,
incorrect_keystrokes INTEGER,
time_in_minutes INTEGER,
extended_seconds INTEGER,
total_minutes TEXT,
typed_words INTEGER,
correct_words INTEGER,
incorrect_words INTEGER,
positive_points INTEGER,
negative_points INTEGER,
all_keypress INTEGER,
interrupted TEXT,
idle TEXT,
challenge_mode TEXT,
typewriter_mode TEXT,
net_cpm TEXT,
kpm TEXT,
kph INTEGER,
keyboard_layout TEXT,
keyboard_keys_used INTEGER,
keyboard_keys TEXT,
os_name TEXT,
os_admin TEXT,
event_date TEXT
)""")
conn3.commit()
conn3 = sqlite3.connect("typewriter.db")
cursor3 = conn3.cursor()
cursor3.execute("""CREATE TABLE IF NOT EXISTS layout (layout)""")
conn3.commit()
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
cursor3.execute("DELETE FROM layout")
conn3.commit()
update_uptimer = True
uptimer = 0
def uptime():
global update_uptimer , uptimer
if update_uptimer:
hours = uptimer // 3600
hours = int(hours)
uptimer_residual = uptimer % 3600
minutes = uptimer_residual // 60
minutes = int(minutes)
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
seconds = uptimer % 60
seconds = int(seconds)
uptime_label.configure(text=f"Uptime: {hours:02d}:{minutes:02d}:{seconds:02d}")
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
uptimer += 1
if total_stat == "On":
uptime_label.after(1000, uptime)
go = False
typewriter_stat = "Off"
def activate_typewriter():
global typewriter_stat , time_remaining , selected_mode , go , time_interval , what_color
if typewriter_stat == "Off":
what_color = ""
time_remaining = typewriter_duration_entry.get()
time_interval = time_remaining
selected_mode = selected_button.get()
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
if selected_mode is None or selected_mode == "":
messagebox.showerror("Error", "Please choose session's difficulty mode first!")
return
if time_remaining == "":
messagebox.showerror("Error", "Please Don't Leave the field empty!")
return
if time_remaining == "0":
messagebox.showerror("Error", "Please set the duration from at least 1 minute, to any number as you wish!")
return
try:
time_remaining = int(time_remaining)
except (ValueError , TypeError):
messagebox.showerror("Error", "Please input only numbers representing minutes!")
return
typewriter_duration_entry.delete(0, tk.END)
words_entry.delete(0, tk.END)
selected_button.set("")
minutes_word = "minute"
if time_remaining > 1:
minutes_word = "minutes"
ask = messagebox.askyesno("Begin?", f"In this typing session, you're about to start in the {selected_mode} typing mode for a maximum of {time_remaining} {minutes_word}.\n\n___PROCEED___?")
if ask:
pass
else:
return
typewriter_stat = "On"
typewriter_button.configure(text="_Toggle_OFF_", bg="red")
typewriter_duration_label.configure(bg="#000000", fg="#000000")
typewriter_duration_entry.configure(bg="#000000", fg="#000000")
typewriter_options_frame.place(relx=0.88, rely=0.15, anchor=tk.N)
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
blank_label.configure(bg="#000000", text="", width=35, height=5)
blank_label2.configure(bg="#000000", text="", width=25, height=3)
blank_label.place(relx=0.88, rely=0.15, anchor=tk.N)
blank_label2.place(relx=0.88, rely=0.25, anchor=tk.N)
start_timer()
elif typewriter_stat == "On":
ask = messagebox.askyesno("End?", "You're about to End the current typing session.\n\nDo you confirm?")
if ask:
pass
else:
return
typewriter_stat = "Off"
go = False
typewriter_button.configure(text="__RESTART__", bg="#00ff00")
typewriter_duration_label.configure(bg="#000000", fg="#00ff00")
typewriter_duration_entry.configure(bg="lightgreen", fg="#000000")
words_label.configure(text="____RESTART_THE_ENGINE!____", fg="#00ff00", font="arial 55 bold")
timer_label.configure(text="", fg="#000000")
typewriter_options_frame.place(relx=0.88, rely=0.25, anchor=tk.N)
timer_label.place(relx=0.88, rely=0.51, anchor=tk.N)
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
blank_label.configure(bg="#000000", text="", width=1, height=1)
blank_label2.configure(bg="#000000", text="", width=1, height=1)
blank_label.place(relx=0.88, rely=0.95, anchor=tk.N)
blank_label2.place(relx=0.88, rely=0.95, anchor=tk.N)
words_entry.delete(0, tk.END)
words_entry.configure(fg="#333333", bg="turquoise")
def start_timer():
global time_remaining , indice , saved1 , challenge
indice = 0
try:
time_remaining = (60 * int(time_remaining)) + int(((int(time_remaining)) * (0/100)) * 60) + 4
challenge = False
except (ValueError , TypeError):
return
saved1 = time_remaining
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
if typewriter_stat == "On":
update_timer()
preparation()
else:
return
def update_timer():
global time_remaining , typewriter_stat , stopwatch , go , saved1 , the_user , total_keystrokes , correct_keystrokes , correct_words , incorrect_words , positive_points , negative_points , all_keypress , interrupted , idle , number_of_words , time_interval , color_reset , typewriter_mode
time_remaining = int(time_remaining)
if time_remaining > 0 and typewriter_stat == "On":
words_label.configure(text="")
hours = time_remaining // 3600
time_remaining_residual = time_remaining % 3600
minutes = time_remaining_residual // 60
seconds = time_remaining % 60
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
stopwatch = int(hours) + int(minutes) + int(seconds)
timer_label.configure(text=f"{hours:02d}:{minutes:02d}:{seconds:02d}")
timer_label.place(relx=0.88, rely=0.42, anchor=tk.N)
words_entry.focus_set()
time_remaining -= 1
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
saved2 = time_remaining
if saved1 - saved2 < 5:
if seconds % 2 == 0:
timer_label.configure(fg="yellow")
else:
timer_label.configure(fg="red")
else:
timer_label.configure(fg="#00ff00")
if hours == 0 and minutes == 0 and seconds < 15:
if seconds % 2 == 0:
timer_label.configure(fg="#00ff00")
else:
timer_label.configure(fg="red")
timer_label.after(1000, update_timer)
else:
typewriter_button.configure(text="__RESTART__", bg="#00ff00")
words_label.configure(text="____RESTART_THE_ENGINE!____", fg="#00ff00", font="arial 55 bold")
typewriter_duration_label.configure(bg="#000000", fg="#00ff00")
typewriter_duration_entry.configure(bg="lightgreen", fg="#000000")
typewriter_options_frame.place(relx=0.88, rely=0.25, anchor=tk.N)
timer_label.place(relx=0.88, rely=0.51, anchor=tk.N)
wpm_meter_label.configure(fg="#000000", text="")
blank_label.configure(bg="#000000", text="", width=1, height=1)
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
blank_label2.configure(bg="#000000", text="", width=1, height=1)
total_stat_label.configure(bg="lightgreen", fg="blue", text="STATE: AFK")
uptime_label.configure(bg="lightgreen", fg="blue")
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
system_label.configure(fg="blue", bg="lightgreen")
top_frame_label.configure(bg="lightgreen")
blank_label.place(relx=0.88, rely=0.95, anchor=tk.N)
blank_label2.place(relx=0.88, rely=0.95, anchor=tk.N)
typewriter_duration_entry.delete(0, tk.END)
words_entry.delete(0, tk.END)
words_label2.place(relx=0.88, rely=0.95, anchor=tk.N)
words_label3.place(relx=0.88, rely=0.95, anchor=tk.N)
words_label4.place(relx=0.88, rely=0.95, anchor=tk.N)
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_label5.place(relx=0.88, rely=0.95, anchor=tk.N)
words_label6.place(relx=0.88, rely=0.95, anchor=tk.N)
words_label7.place(relx=0.88, rely=0.95, anchor=tk.N)
words_label8.place(relx=0.88, rely=0.95, anchor=tk.N)
words_label9.place(relx=0.88, rely=0.95, anchor=tk.N)
words_label10.place(relx=0.88, rely=0.95, anchor=tk.N)
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_label11.place(relx=0.88, rely=0.95, anchor=tk.N)
words_label12.place(relx=0.88, rely=0.95, anchor=tk.N)
words_label13.place(relx=0.88, rely=0.95, anchor=tk.N)
words_label14.place(relx=0.88, rely=0.95, anchor=tk.N)
words_label15.place(relx=0.88, rely=0.95, anchor=tk.N)
words_label16.place(relx=0.88, rely=0.95, anchor=tk.N)
words_label17.place(relx=0.88, rely=0.95, anchor=tk.N)
words_label2.configure(bg="#000000", fg="#000000", text="")
words_label3.configure(bg="#000000", fg="#000000", text="")
words_label4.configure(bg="#000000", fg="#000000", text="")
words_label5.configure(bg="#000000", fg="#000000", text="")
words_label6.configure(bg="#000000", fg="#000000", text="")
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_label7.configure(bg="#000000", fg="#000000", text="")
words_label8.configure(bg="#000000", fg="#000000", text="")
words_label9.configure(bg="#000000", fg="#000000", text="")
words_label10.configure(bg="#000000", fg="#000000", text="")
words_label11.configure(bg="#000000", fg="#000000", text="")
words_label12.configure(bg="#000000", fg="#000000", text="")
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_label13.configure(bg="#000000", fg="#000000", text="")
words_label14.configure(bg="#000000", fg="#000000", text="")
words_label15.configure(bg="#000000", fg="#000000", text="")
words_label16.configure(bg="#000000", fg="#000000", text="")
words_label17.configure(bg="#000000", fg="#000000", text="")
color_reset = "yes"
radiobutton_entry_focus()
# Some arithmetic paperworks:
typewriter_mode = typewriter_mode
difficulty = selected_mode
username = the_user
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
extended_seconds = int((int(time_interval)*60) * (0/100))
total_score = positive_points - negative_points
keyboard_layout = "QWERTY"
conn3 = sqlite3.connect("typewriter.db")
cursor3 = conn3.cursor()
cursor3.execute("""CREATE TABLE IF NOT EXISTS layout (layout)""")
conn3.commit()
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
cursor3.execute("SELECT layout FROM layout")
k_layout = cursor3.fetchone()
if k_layout == None:
k_layout = str(k_layout)
else:
for layout in k_layout:
keyboard_layout = str(layout)
try:
gross_wpm = int((total_keystrokes/5)/(float(time_interval)))
net_wpm = ((correct_keystrokes + (number_of_words-1))/5)/(float(time_interval))
pure_wpm = (correct_keystrokes/5)/(float(time_interval))
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
accuracy = int((correct_keystrokes+(number_of_words-1))*100/total_keystrokes)
correct_chars = correct_keystrokes
total_keystrokes = total_keystrokes
if correct_keystrokes > 0:
correct_keystrokes += (number_of_words-1)
else:
correct_keystrokes = correct_keystrokes
incorrect_keystrokes = total_keystrokes - correct_keystrokes
time_in_minutes = float(time_interval)
total_minutes = int(time_interval) + (extended_seconds/60)
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
correct_words = correct_words
incorrect_words = incorrect_words
positive_points = positive_points
negative_points = negative_points
all_keypress = all_keypress
idle = "False"
challenge_mode = str(challenge)
net_cpm = (correct_keystrokes/float(time_interval))
kpm = (total_keystrokes/float(time_interval))
kph = int(total_keystrokes/(float(time_interval)/60))
typed_words = number_of_words
os_name = platform.system()
os_admin = getpass.getuser()
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
event_date = str(datetime.datetime.now())
except ZeroDivisionError:
gross_wpm = "N/A"
net_wpm = "N/A"
pure_wpm = "N/A"
accuracy = "N/A"
correct_chars = correct_keystrokes
total_keystrokes = total_keystrokes
if correct_keystrokes > 0:
correct_keystrokes += (number_of_words-1)
else:
correct_keystrokes = correct_keystrokes
incorrect_keystrokes = total_keystrokes - correct_keystrokes
time_in_minutes = int(time_interval)
total_minutes = int(time_interval) + (extended_seconds/60)
correct_words = correct_words
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
incorrect_words = incorrect_words
positive_points = positive_points
negative_points = negative_points
all_keypress = all_keypress
idle = "False"
challenge_mode = str(challenge)
net_cpm = "N/A"
kpm = "N/A"
kph = "N/A"
typed_words = number_of_words
os_name = platform.system()
os_admin = getpass.getuser()
event_date = str(datetime.datetime.now())
if correct_words == 0:
net_wpm = "N/A"
gross_wpm = "N/A"
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
pure_wpm = "N/A"
accuracy = "N/A"
correct_chars = "N/A"
correct_keystrokes = "N/A"
incorrect_keystrokes = "N/A"
net_cpm = "N/A"
kpm = "N/A"
kph = "N/A"
if challenge:
total_score += int(0.15*total_score)
extended_seconds = 0
total_minutes = int(time_interval) + (extended_seconds/60)
if typewriter_stat == "Off":
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
timer_label.configure(text="Process Stopped Manually!", fg="#00ff00")
interrupted = "True"
messagebox.showinfo(f"{username}'s RESULTS:", f"YOU CAN'T SAVE YOUR PROGRESS BECAUSE YOU HAVE ENDED THE SESSION MANUALLY! HOWEVER, THE INCOMPLETE RESULTS WOULD BE AS FOLLOWS:\n\n\t--------- S C O R E --------- \n\n\t 1. Score: {total_score} PTS\n\n\t--------- W P M --------- \n\n\t 2. Net WPM: {net_wpm} WPM\n\t 3. Gross WPM: {gross_wpm} WPM\n\t 4. Pure WPM: {pure_wpm} WPM\n\n\t--------- A C C U R A C Y --------- \n\n\t 5. Accuracy: {accuracy}%\n\n\t--------- C H A R A C T E R S --------- \n\n\t 6. Correct Characters: {correct_chars} Char(s)\n\n\t--------- K E Y . S T R O K E S --------- \n\n\t 7. Total Keystrokes: {total_keystrokes} Stroke(s)\n\t 8. Correct Keystrokes: {correct_keystrokes} Stroke(s)\n\t 9. Incorrect Keystrokes: {incorrect_keystrokes} Stroke(s)\n\n\t--------- T I M E --------- \n\n\t 10. Time In Minutes: {time_in_minutes} Minute(s)\n\t 11. Extended Seconds: {extended_seconds} Second(s)\n\t 12. Total Minutes: {total_minutes} Minute(s)\n\n\t--------- W O R D S --------- \n\n\t 13. All Typed Words: {typed_words} Word(s)\n\t 14. Correct Words: {correct_words} Word(s)\n\t 15. Incorrect Words: {incorrect_words} Word(s)\n\n\t--------- P O I N T S --------- \n\n\t 16. Positive Points: {positive_points} PTS\n\t 17. Negative Points: -{negative_points} PTS\n\n\t--------- S T A T S --------- \n\n\t 18. All Keys Pressed: {all_keypress} Key(s)\n\t 19. Stopped by User? {interrupted}\n\t 20. Idle? {idle}\n\t 21. Session On Challenge Mode? {challenge_mode}\n\n\t--------- N O N - W P M --------- \n\n\t 22. Net CPM: {net_cpm} CPM\n\t 23. KPM: {kpm} KPM\n\t 24. KPH: {kph} KPH")
radiobutton_entry_focus()
else:
timer_label.configure(text="Time's up!", fg="#00ff00")
words_entry.configure(bg="turquoise", fg="#333333")
typewriter_stat = "Off"
interrupted = "False"
go = False
wpm_measure = 15
try:
wpm_measure = int(net_wpm)
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
except (ValueError , TypeError):
pass
if wpm_measure < 15 or net_wpm == "N/A":
idle = "True"
messagebox.showinfo("Idle_True", "Apologies, Sounds like you were AFK or completely idle for sometime. Hence, your progress cannot be saved nor will it be represented to you by any means or by any possible way, only & only because you went AFK during an ongoing session!")
return
else:
messagebox.showinfo("Time's Over!", "Successfully carried out the test and completed a session!\nTherefore, you are being redirected to your results shortly ...")
store_message = messagebox.askyesno(f"{username}'s RESULTS:", f"\t--------- S C O R E --------- \n\n\t 1. Score: {total_score} PTS\n\n\t--------- W P M --------- \n\n\t 2. Net WPM: {net_wpm} WPM\n\t 3. Gross WPM: {gross_wpm} WPM\n\t 4. Pure WPM: {pure_wpm} WPM\n\n\t--------- A C C U R A C Y --------- \n\n\t 5. Accuracy: {accuracy}%\n\n\t--------- C H A R A C T E R S --------- \n\n\t 6. Correct Characters: {correct_chars} Char(s)\n\n\t--------- K E Y . S T R O K E S --------- \n\n\t 7. Total Keystrokes: {total_keystrokes} Stroke(s)\n\t 8. Correct Keystrokes: {correct_keystrokes} Stroke(s)\n\t 9. Incorrect Keystrokes: {incorrect_keystrokes} Stroke(s)\n\n\t--------- T I M E --------- \n\n\t 10. Time In Minutes: {time_in_minutes} Minute(s)\n\t 11. Extended Seconds: {extended_seconds} Second(s)\n\t 12. Total Minutes: {total_minutes} Minute(s)\n\n\t--------- W O R D S --------- \n\n\t 13. All Typed Words: {typed_words} Word(s)\n\t 14. Correct Words: {correct_words} Word(s)\n\t 15. Incorrect Words: {incorrect_words} Word(s)\n\n\t--------- P O I N T S --------- \n\n\t 16. Positive Points: {positive_points} PTS\n\t 17. Negative Points: -{negative_points} PTS\n\n\t--------- S T A T S --------- \n\n\t 18. All Keys Pressed: {all_keypress} Key(s)\n\t 19. Stopped by User? {interrupted}\n\t 20. Idle? {idle}\n\t 21. Session On Challenge Mode? {challenge_mode}\n\n\t--------- N O N - W P M --------- \n\n\t 22. Net CPM: {net_cpm} CPM\n\t 23. KPM: {kpm} KPM\n\t 24. KPH: {kph} KPH\n\n\n\t********* ___SAVE STATS?___ ********* ")
radiobutton_entry_focus()
if store_message:
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
conn3 = sqlite3.connect("typewriter.db")
cursor3 = conn3.cursor()
cursor3.execute("INSERT INTO records (username, total_score, net_wpm, gross_wpm, pure_wpm, accuracy, correct_chars, total_keystrokes, correct_keystrokes, incorrect_keystrokes, time_in_minutes, extended_seconds, total_minutes, typed_words, correct_words, incorrect_words, positive_points, negative_points, all_keypress, interrupted, idle, challenge_mode, typewriter_mode, net_cpm, kpm, kph, keyboard_layout, keyboard_keys_used, keyboard_keys, os_name, os_admin, event_date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", (username, total_score, f"{net_wpm} WPM", gross_wpm, pure_wpm, f"{accuracy}%", correct_chars, total_keystrokes, correct_keystrokes, incorrect_keystrokes, f"{time_in_minutes} m", f"{extended_seconds} s", f"{total_minutes} m", typed_words, correct_words, incorrect_words, positive_points, -negative_points, all_keypress, interrupted, idle, challenge_mode, f"{typewriter_mode}, {difficulty}", net_cpm, kpm, kph, keyboard_layout, len(keyboard_keys_used), f"{tuple(keyboard_keys_used)}", os_name, os_admin, event_date))
conn3.commit()
lb_check = messagebox.askyesno("STORED!", "Results sucessfully transferred and saved into the database!\n\nAnd additionally ... **___ONE FINAL THING:___\nWould you like to check out the Leaderboard?")
if lb_check:
subprocess.Popen(['python', 'leaderboard.py'])
else:
return
else:
return
def preparation():
global indice , go , preparation_count , positive_points , negative_points , total_keystrokes , correct_keystrokes , random_word , number_of_words , correct_words , incorrect_words , all_keypress , realtime_stroke_aggregator , meter_timer , wpm_calc , keyboard_keys_used , color_reset , random_state , start
go = False
if typewriter_stat == "On":
preparation_count_list = ["WAIT ... <-----Three----->", "WAIT ... <-----Two----->", "WAIT ... <-----One----->", "<-----Go!----->"]
if indice < 4:
preparation_count = preparation_count_list[indice]
indice += 1
if indice < 4:
words_label.configure(text=preparation_count, fg="red", font="arial 45 italic")
elif indice == 4:
words_label.configure(text=preparation_count, fg="yellow", font="arial 45 italic")
words_label.after(1000, preparation)
elif indice == 4:
random_word = ""
positive_points = 0
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
negative_points = 0
total_keystrokes = 0
all_keypress = 0
correct_keystrokes = 0
number_of_words = 0
correct_words = 0
incorrect_words = 0
realtime_stroke_aggregator = 0
meter_timer = 0
wpm_calc = 0
random_state = "0"
keyboard_keys_used = []
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
color_reset = "yes"
start = "1"
go = True
words_entry.delete(0, tk.END)
words()
realtime_wpm_meter_timer()
realtime_wpm_meter()
idle_timeout_check()
words_label.configure(text="")
return
else:
return
def idle_timeout_check():
global stopwatch , go , typewriter_stat
if stopwatch == 0:
go = False
typewriter_stat = "Off"
words_label.after(1000, idle_timeout_check)
def words():
global typewriter_stat , stopwatch , english_words_essential , english_words_advanced , english_words_full , selected_mode , go , preparation_count , positive_points , negative_points , correct_keystrokes , random_word , time_interval , number_of_words , correct_words , incorrect_words , all_keypress , realtime_stroke_aggregator , keyboard_keys_used , random_state , color_reset , start , random_word1 , random_word2 , random_word3 , random_word4 , random_word5 , random_word6 , random_word8, random_word9 , random_word10 , random_word11 , random_word12 , random_word13 , random_word14 , random_word15 , random_word16 , random_word17 , total_keystrokes
if go:
pass
else:
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_entry.delete(0, tk.END)
return
words_label.configure(fg="#00ff00", font="arial 55 bold")
if typewriter_stat == "On":
if stopwatch == 0:
return
else:
pass
if selected_mode == "'Essential'":
total_stat_label.configure(bg="darkblue", fg="yellow", text=f"STATE: During a {time_interval}-Minute Essential Words Typing Session")
top_frame_label.configure(bg="darkblue")
uptime_label.configure(fg="yellow", bg="darkblue")
system_label.configure(fg="yellow", bg="darkblue")
words_label2.place(relx=0.11, rely=0.055, anchor=tk.N)
words_label3.place(relx=0.22, rely=0.055, anchor=tk.N)
words_label4.place(relx=0.33, rely=0.055, anchor=tk.N)
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_label5.place(relx=0.44, rely=0.055, anchor=tk.N)
words_label6.place(relx=0.55, rely=0.055, anchor=tk.N)
words_label7.place(relx=0.66, rely=0.055, anchor=tk.N)
words_label8.place(relx=0.77, rely=0.055, anchor=tk.N)
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_label9.place(relx=0.88, rely=0.055, anchor=tk.N)
words_label10.place(relx=0.11, rely=0.11, anchor=tk.N)
words_label11.place(relx=0.22, rely=0.11, anchor=tk.N)
words_label12.place(relx=0.33, rely=0.11, anchor=tk.N)
words_label13.place(relx=0.44, rely=0.11, anchor=tk.N)
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_label14.place(relx=0.55, rely=0.11, anchor=tk.N)
words_label15.place(relx=0.66, rely=0.11, anchor=tk.N)
words_label16.place(relx=0.77, rely=0.11, anchor=tk.N)
words_label17.place(relx=0.88, rely=0.11, anchor=tk.N)
preparation_count = ""
typewriter_word = words_entry.get()
if start == "1":
random_word1 = random.choice(english_words_essential)
words_label2.configure(text=f"{random_word1}")
random_word2 = random.choice(english_words_essential)
words_label3.configure(text=f"{random_word2}")
random_word3 = random.choice(english_words_essential)
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_label4.configure(text=f"{random_word3}")
random_word4 = random.choice(english_words_essential)
words_label5.configure(text=f"{random_word4}")
random_word5 = random.choice(english_words_essential)
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_label6.configure(text=f"{random_word5}")
random_word6 = random.choice(english_words_essential)
words_label7.configure(text=f"{random_word6}")
random_word8 = random.choice(english_words_essential)
words_label8.configure(text=f"{random_word8}")
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
random_word9 = random.choice(english_words_essential)
words_label9.configure(text=f"{random_word9}")
random_word10 = random.choice(english_words_essential)
words_label10.configure(text=f"{random_word10}")
random_word11 = random.choice(english_words_essential)
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_label11.configure(text=f"{random_word11}")
random_word12 = random.choice(english_words_essential)
words_label12.configure(text=f"{random_word12}")
random_word13 = random.choice(english_words_essential)
words_label13.configure(text=f"{random_word13}")
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
random_word14 = random.choice(english_words_essential)
words_label14.configure(text=f"{random_word14}")
random_word15 = random.choice(english_words_essential)
words_label15.configure(text=f"{random_word15}")
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
random_word16 = random.choice(english_words_essential)
words_label16.configure(text=f"{random_word16}")
random_word17 = random.choice(english_words_essential)
words_label17.configure(text=f"{random_word17}")
start = "0"
if color_reset == "yes":
words_label2.configure(fg="#00ff00")
words_label3.configure(fg="#00ff00")
words_label4.configure(fg="#00ff00")
words_label5.configure(fg="#00ff00")
words_label6.configure(fg="#00ff00")
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_label7.configure(fg="#00ff00")
words_label8.configure(fg="#00ff00")
words_label9.configure(fg="#00ff00")
words_label10.configure(fg="#00ff00")
words_label11.configure(fg="#00ff00")
words_label12.configure(fg="#00ff00")
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_label13.configure(fg="#00ff00")
words_label14.configure(fg="#00ff00")
words_label15.configure(fg="#00ff00")
words_label16.configure(fg="#00ff00")
words_label17.configure(fg="#00ff00")
if typewriter_word.count(" ") == len(typewriter_word):
words_entry.delete(0, tk.END)
if random_state != "1" and random_state != "2" and random_state != "3" and random_state != "4" and random_state != "5" and random_state != "6" and random_state != "7" and random_state != "8" and random_state != "9" and random_state != "10" and random_state != "11" and random_state != "12" and random_state != "13" and random_state != "14" and random_state != "15" and random_state != "16":
words_entry.delete(0, tk.END)
random_word = random_word1
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
random_state = "1"
color_reset = "no"
#words_label(s) are configured to pose as cursors to the word being typed:
words_label2.configure(bg="#555555")
allowed_space_count = random_word.count(" ") + 1
random_state = str(random_state)
if ((typewriter_word.count(" ") >= allowed_space_count) and (typewriter_word[len(typewriter_word)-1] == " ") and (typewriter_word[len(typewriter_word)-2:len(typewriter_word)] != " ")) and (len(typewriter_word) >= len(random_word) or (len(random_word) - len(typewriter_word)) < 3) and " " not in typewriter_word:
tks = len(typewriter_word)
number_of_words += 1
if random_word17 == typewriter_word[:len(typewriter_word)-1] and random_state == "16":
words_entry.delete(0, tk.END)
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
typewriter_word = ""
random_state = "0"
color_reset = "yes"
words_label17.configure(bg="#000000")
correct_words += 1
positive_points += 5
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
total_keystrokes += tks
correct_keystrokes += len(random_word17)
words_entry.configure(fg="#333333", bg="turquoise")
elif random_word17 != typewriter_word[:len(typewriter_word)-1] and random_state == "16":
words_entry.delete(0, tk.END)
typewriter_word = ""
random_state = "0"
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
color_reset = "yes"
words_label17.configure(bg="#000000")
incorrect_words += 1
negative_points += 10
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
total_keystrokes += tks
correct_keystroke_aggregator = []
penalty = 1
for char in random_word17:
if char in typewriter_word:
correct_keystroke_aggregator.append(char)
correct_keystrokes += (len(correct_keystroke_aggregator) - int(penalty))
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_entry.configure(fg="#333333", bg="turquoise")
if random_word16 == typewriter_word[:len(typewriter_word)-1] and random_state == "15":
words_entry.delete(0, tk.END)
typewriter_word = ""
random_word = random_word17
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
random_state = "16"
words_label17.configure(bg="#555555")
words_label16.configure(bg="#000000")
correct_words += 1
positive_points += 5
total_keystrokes += tks
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
correct_keystrokes += len(random_word16)
words_entry.configure(fg="#333333", bg="turquoise")
elif random_word16 != typewriter_word[:len(typewriter_word)-1] and random_state == "15":
words_entry.delete(0, tk.END)
typewriter_word = ""
random_word = random_word17
random_state = "16"
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_label17.configure(bg="#555555")
words_label16.configure(bg="#000000")
incorrect_words += 1
negative_points += 10
total_keystrokes += tks
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
correct_keystroke_aggregator = []
penalty = 1
for char in random_word16:
if char in typewriter_word:
correct_keystroke_aggregator.append(char)
correct_keystrokes += (len(correct_keystroke_aggregator) - int(penalty))
words_entry.configure(fg="#333333", bg="turquoise")
if random_word15 == typewriter_word[:len(typewriter_word)-1] and random_state == "14":
words_entry.delete(0, tk.END)
typewriter_word = ""
random_word = random_word16
random_state = "15"
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_label16.configure(bg="#555555")
words_label15.configure(bg="#000000")
correct_words += 1
positive_points += 5
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
total_keystrokes += tks
correct_keystrokes += len(random_word15)
words_entry.configure(fg="#333333", bg="turquoise")
elif random_word15 != typewriter_word[:len(typewriter_word)-1] and random_state == "14":
words_entry.delete(0, tk.END)
typewriter_word = ""
random_word = random_word16
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
random_state = "15"
words_label16.configure(bg="#555555")
words_label15.configure(bg="#000000")
incorrect_words += 1
negative_points += 10
total_keystrokes += tks
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
correct_keystroke_aggregator = []
penalty = 1
for char in random_word15:
if char in typewriter_word:
correct_keystroke_aggregator.append(char)
correct_keystrokes += (len(correct_keystroke_aggregator) - int(penalty))
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_entry.configure(fg="#333333", bg="turquoise")
if random_word14 == typewriter_word[:len(typewriter_word)-1] and random_state == "13":
words_entry.delete(0, tk.END)
typewriter_word = ""
random_word = random_word15
random_state = "14"
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_label15.configure(bg="#555555")
words_label14.configure(bg="#000000")
correct_words += 1
positive_points += 5
total_keystrokes += tks
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
correct_keystrokes += len(random_word14)
words_entry.configure(fg="#333333", bg="turquoise")
elif random_word14 != typewriter_word[:len(typewriter_word)-1] and random_state == "13":
words_entry.delete(0, tk.END)
typewriter_word = ""
random_word = random_word15
random_state = "14"
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_label15.configure(bg="#555555")
words_label14.configure(bg="#000000")
incorrect_words += 1
negative_points += 10
total_keystrokes += tks
correct_keystroke_aggregator = []
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
penalty = 1
for char in random_word14:
if char in typewriter_word:
correct_keystroke_aggregator.append(char)
correct_keystrokes += (len(correct_keystroke_aggregator) - int(penalty))
words_entry.configure(fg="#333333", bg="turquoise")
if random_word13 == typewriter_word[:len(typewriter_word)-1] and random_state == "12":
words_entry.delete(0, tk.END)
typewriter_word = ""
random_word = random_word14
random_state = "13"
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_label14.configure(bg="#555555")
words_label13.configure(bg="#000000")
correct_words += 1
positive_points += 5
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
total_keystrokes += tks
correct_keystrokes += len(random_word13)
words_entry.configure(fg="#333333", bg="turquoise")
elif random_word13 != typewriter_word[:len(typewriter_word)-1] and random_state == "12":
words_entry.delete(0, tk.END)
typewriter_word = ""
random_word = random_word14
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
random_state = "13"
words_label14.configure(bg="#555555")
words_label13.configure(bg="#000000")
incorrect_words += 1
negative_points += 10
total_keystrokes += tks
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
correct_keystroke_aggregator = []
penalty = 1
for char in random_word13:
if char in typewriter_word:
correct_keystroke_aggregator.append(char)
correct_keystrokes += (len(correct_keystroke_aggregator) - int(penalty))
words_entry.configure(fg="#333333", bg="turquoise")
if random_word12 == typewriter_word[:len(typewriter_word)-1] and random_state == "11":
words_entry.delete(0, tk.END)
typewriter_word = ""
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
random_word = random_word13
random_state = "12"
words_label13.configure(bg="#555555")
words_label12.configure(bg="#000000")
correct_words += 1
positive_points += 5
total_keystrokes += tks
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
correct_keystrokes += len(random_word12)
words_entry.configure(fg="#333333", bg="turquoise")
elif random_word12 != typewriter_word[:len(typewriter_word)-1] and random_state == "11":
words_entry.delete(0, tk.END)
typewriter_word = ""
random_word = random_word13
random_state = "12"
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_label13.configure(bg="#555555")
words_label12.configure(bg="#000000")
incorrect_words += 1
negative_points += 10
total_keystrokes += tks
correct_keystroke_aggregator = []
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
penalty = 1
for char in random_word12:
if char in typewriter_word:
correct_keystroke_aggregator.append(char)
correct_keystrokes += (len(correct_keystroke_aggregator) - int(penalty))
words_entry.configure(fg="#333333", bg="turquoise")
if random_word11 == typewriter_word[:len(typewriter_word)-1] and random_state == "10":
words_entry.delete(0, tk.END)
typewriter_word = ""
random_word = random_word12
random_state = "11"
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_label12.configure(bg="#555555")
words_label11.configure(bg="#000000")
correct_words += 1
positive_points += 5
total_keystrokes += tks
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
correct_keystrokes += len(random_word11)
words_entry.configure(fg="#333333", bg="turquoise")
elif random_word11 != typewriter_word[:len(typewriter_word)-1] and random_state == "10":
words_entry.delete(0, tk.END)
typewriter_word = ""
random_word = random_word12
random_state = "11"
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_label12.configure(bg="#555555")
words_label11.configure(bg="#000000")
incorrect_words += 1
negative_points += 10
total_keystrokes += tks
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
correct_keystroke_aggregator = []
penalty = 1
for char in random_word11:
if char in typewriter_word:
correct_keystroke_aggregator.append(char)
correct_keystrokes += (len(correct_keystroke_aggregator) - int(penalty))
words_entry.configure(fg="#333333", bg="turquoise")
if random_word10 == typewriter_word[:len(typewriter_word)-1] and random_state == "9":
words_entry.delete(0, tk.END)
typewriter_word = ""
random_word = random_word11
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
random_state = "10"
words_label11.configure(bg="#555555")
words_label10.configure(bg="#000000")
correct_words += 1
positive_points += 5
total_keystrokes += tks
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
correct_keystrokes += len(random_word10)
words_entry.configure(fg="#333333", bg="turquoise")
elif random_word10 != typewriter_word[:len(typewriter_word)-1] and random_state == "9":
words_entry.delete(0, tk.END)
typewriter_word = ""
random_word = random_word11
random_state = "10"
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
words_label11.configure(bg="#555555")
words_label10.configure(bg="#000000")
incorrect_words += 1
negative_points += 10
total_keystrokes += tks
correct_keystroke_aggregator = []
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
penalty = 1
for char in random_word10:
if char in typewriter_word:
correct_keystroke_aggregator.append(char)
correct_keystrokes += (len(correct_keystroke_aggregator) - int(penalty))
words_entry.configure(fg="#333333", bg="turquoise")
if random_word9 == typewriter_word[:len(typewriter_word)-1] and random_state == "8":
words_entry.delete(0, tk.END)
typewriter_word = ""
random_word = random_word10
random_state = "9"
words_label10.configure(bg="#555555")
words_label9.configure(bg="#000000")
# Copyright (C) [2023] [Mohammad Dorri] <[https://www.github.com/PG6AW]>
correct_words += 1