Skip to content

Commit

Permalink
Add exception
Browse files Browse the repository at this point in the history
  • Loading branch information
neihousaigaai authored Aug 2, 2017
1 parent 03411c4 commit 836ee19
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
Binary file modified test-app.exe
Binary file not shown.
35 changes: 21 additions & 14 deletions test-app.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def MainWindow(event):
T = -1

if not (questions != '' and N > 0 and subject != '' and name != '' and _time != '' and T > 0):
messagebox.showinfo("Notification", "Invalid input!")
return None

win.destroy()
Expand Down Expand Up @@ -70,7 +71,7 @@ def countdown():
stopButton.config(state=DISABLED)
Answer(DISABLED)
if (_h + _m + _s == 0):
messagebox.showinfo("Notification", "Test has been ended.", )
messagebox.showinfo("Notification", "Test has been ended.")
return None

global time_lasted
Expand Down Expand Up @@ -122,7 +123,7 @@ def Check():

s = filedialog.askopenfilename(filetypes=[("Text files", "*.txt")])

fi = open(s, 'r')
fi = open(s, 'r', encoding='utf8')
while 1 == 1:
ss = fi.readline()
if len(ss) == 0:
Expand All @@ -140,15 +141,21 @@ def Check():
blank = 0

for i in range(1, N + 1):
if var[i].get() == ans[i]:
resLab[i].config(text=u'\u2713', fg="#00FF00")
true += 1
else:
resLab[i].config(text=u'\u2717', fg="#FF0000")
if (var[i].get() != "E"):
false += 1
if i in ans:
if var[i].get() == ans[i]:
resLab[i].config(text=u'\u2713', fg="#00FF00")
true += 1
else:
blank += 1
resLab[i].config(text=u'\u2717', fg="#FF0000")
if (var[i].get() != "E"):
false += 1
else:
blank += 1

else:
messagebox.showinfo("Notification", "Your answer file is missing some questions...")
return None

exportButton.config(state=NORMAL)

global score
Expand Down Expand Up @@ -281,19 +288,19 @@ def Export():
fr2.pack()
fr2.place(x=_L, y=35, height=_h, width=4*(_w+_d)-_d)

startButton=Button(fr2, text="Start", command=Start, state=NORMAL)
startButton = Button(fr2, text="Start", command=Start, state=NORMAL)
startButton.pack()
startButton.place(x=0, y=0, height=_h, width=_w)

stopButton=Button(fr2, text="Stop", command=Stop, state=DISABLED)
stopButton = Button(fr2, text="Stop", command=Stop, state=DISABLED)
stopButton.pack()
stopButton.place(x=_w+_d, y=0, height=_h, width=_w)

checkButton=Button(fr2, text="Check", command=Check, state=DISABLED)
checkButton = Button(fr2, text="Check", command=Check, state=DISABLED)
checkButton.pack()
checkButton.place(x=2*(_w+_d), y=0, height=_h, width=_w)

exportButton=Button(fr2, text="Export", command=Export, state=DISABLED)
exportButton = Button(fr2, text="Export", command=Export, state=DISABLED)
exportButton.pack()
exportButton.place(x=3*(_w+_d), y=0, height=_h, width=_w)

Expand Down

0 comments on commit 836ee19

Please sign in to comment.