-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_no_py.py
174 lines (156 loc) · 5.91 KB
/
main_no_py.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
from tkinter import *
import pandas
import random
import time
#from sklearn.utils import shuffle
#df = shuffle(df)
df = pandas.read_csv("HSK/HSK_3_no_pinyin.csv")
column_list = []
right = 0
wrong = 0
current_word = 0
word_count_list = []
wrong_words = []
def inc_r():
global current_word
a = len(df) - 1
if current_word == a:
current_word = 0
global right
right += 1
l1 = Label(window,text=getText(),width=15,height=5,font=("Helvetica", 32))
l1.grid(row=0, column=1)
l2 = Label(window,text="Right: {}".format(right),width=15,height=5,font=("Helvetica", 32))
l2.grid(row=0, column=0)
l3 = Label(window,text="Wrong: {}".format(wrong),width=15,height=5,font=("Helvetica", 32))
l3.grid(row=0, column=2)
global column_list
column_list = []
b2 = Button(window,text=getAnsText(),command=inc_r,width=12,height=3,font=("Helvetica", 32))
b2.grid(column=Retrieve_Random_Column_Number(),row=1)
b1 = Button(window,text=getRandomText(),command=inc_w,width=12,height=3,font=("Helvetica", 32))
b1.grid(column=Retrieve_Random_Column_Number(),row=1)
b3 = Button(window,text=getRandomText(),command=inc_w,width=12,height=3,font=("Helvetica", 32))
b3.grid(column=Retrieve_Random_Column_Number(),row=1)
def inc_w():
global wrong_words
global current_word
a = current_word - 1
if a in wrong_words:
pass
else:
wrong_words.append(a)
a = len(df) - 1
if current_word == a:
current_word = 0
global wrong
wrong += 1
l1 = Label(window,text=getText(),width=15,height=5,font=("Helvetica", 32))
l1.grid(row=0, column=1)
l2 = Label(window,text="Right: {}".format(right),width=15,height=5,font=("Helvetica", 32))
l2.grid(row=0, column=0)
l3 = Label(window,text="Wrong: {}".format(wrong),width=15,height=5,font=("Helvetica", 32))
l3.grid(row=0, column=2)
global column_list
column_list = []
b2 = Button(window,text=getAnsText(),command=inc_r,width=12,height=3,font=("Helvetica", 32))
b2.grid(column=Retrieve_Random_Column_Number(),row=1)
b1 = Button(window,text=getRandomText(),command=inc_w,width=12,height=3,font=("Helvetica", 32))
b1.grid(column=Retrieve_Random_Column_Number(),row=1)
b3 = Button(window,text=getRandomText(),command=inc_w,width=12,height=3,font=("Helvetica", 32))
b3.grid(column=Retrieve_Random_Column_Number(),row=1)
for i in wrong_words:
print(df.iloc[i,0])
print("\n\n\n\n")
def exit():
global wrong_words
global column_list
global right
global wrong
global current_word
global word_count_list
global window_2
window.quit()
window_2 = Tk()
window_2.wm_title("Session Summary")
window_2.geometry("395x690+850+100")
label_2 = Label(window_2,text="Words to review",width=15,height=4,font=("Helvetica", 32),highlightbackground="red",borderwidth=5)
label_2.grid(column=0,row=0)
list1 = Listbox(window_2,font=("Helvetica", 32))
list1.grid(row=1,column=0,columnspan=10,rowspan=10,padx=20,pady=20)
for i in wrong_words:
if df.iloc[i,0] == "B":
pass
else:
list1.insert(END,df.iloc[i,0] + " : " + df.iloc[i,1])
column_list = []
right = 0
wrong = 0
current_word = 0
word_count_list = []
wrong_words = []
button_1 = Button(window_2,text="Go again",height=2,width=8,font=("Helvetica", 32),highlightbackground="red",highlightthickness=5,command=destroy_2)
button_1.grid(row=13,column=0,padx=32,pady=32)
window_2.mainloop()
def destroy_2():
global window_2
window_2.destroy()
l2 = Label(window,text="Right: 0",width=15,height=5,font=("Helvetica", 32))
l2.grid(row=0, column=0)
l3 = Label(window,text="Wrong: 0",width=15,height=5,font=("Helvetica", 32))
l3.grid(row=0, column=2)
def getText():
global text
global current_word
global random_letter_var
random_letter_var = random.randrange(0,len(df))
text = df.iloc[current_word,0]
while text == "B":
random_letter_var = random.randrange(0,len(df))
text = df.iloc[current_word,0]
return text
def getAnsText():
global AnsText
global current_word
AnsText = df.iloc[current_word,1]
current_word += 1
return AnsText
def getRandomText():
randomNum = random.randrange(0,len(df))
RandomText = df.iloc[randomNum,1]
while RandomText == AnsText:
randomNum = random.randrange(0,len(df))
RandomText = df.iloc[randomNum,1]
return RandomText
def Retrieve_Random_Column_Number():
column = random.randrange(0,3)
if column in column_list:
while(column in column_list):
column = random.randrange(0,3)
column_list.append(column)
return column
else:
column_list.append(column)
return column
window = Tk()
window.wm_title("Active Session")
window.geometry("832x432+0+100")
l1 = Label(window,text=getText(),width=15,height=5,font=("Helvetica", 32))
l1.grid(row=0, column=1)
l2 = Label(window,text="Right: {}".format(right),width=15,height=5,font=("Helvetica", 32))
l2.grid(row=0, column=0)
l3 = Label(window,text="Wrong: {}".format(wrong),width=15,height=5,font=("Helvetica", 32))
l3.grid(row=0, column=2)
b2 = Button(window,text=getAnsText(),command=inc_r,width=15,height=3,font=("Helvetica", 32))
b2.grid(column=Retrieve_Random_Column_Number(),row=1)
b1 = Button(window,text=getRandomText(),command=inc_w,width=15,height=3,font=("Helvetica", 32))
b1.grid(column=Retrieve_Random_Column_Number(),row=1)
b3 = Button(window,text=getRandomText(),command=inc_w,width=15,height=3,font=("Helvetica", 32))
b3.grid(column=Retrieve_Random_Column_Number(),row=1)
lower_label_1 = Label(window,text=" ",width=15,height=5)
lower_label_1.grid(row=2,column=0)
lower_label_2 = Label(window,text=" ",width=15,height=5)
lower_label_2.grid(row=2,column=2)
lower_button_end = Button(window,text="Finish",command=exit,width=12,height=3,font=("Helvetica", 32))
lower_button_end.grid(row=2,column=1)
window.mainloop()