-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgui.py
72 lines (68 loc) · 3.06 KB
/
gui.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
from Tkinter import *
from sugg import *
from inDict import *
from addtoDict import *
from replaceword import *
window = Tk()
frame1 = Frame(window,width = 100,height = 100)
frame1.pack(side=TOP)
frame2 = Frame(window)
frame2.pack(side = BOTTOM)
class searchtext:
def __init__(self,master):
self.entertext = Text(master,width=160,height=10)#creates an entry box
self.entertext.pack(fill=X)
frame1 = Frame(master,width = 100,height = 100)#creates a frame in the window of height 100 and width 100
frame1.pack(side=TOP)#packs frame in the left side of the window
#self.button1 = Button(frame1,text="Add to dictionary",command=self.printmessage)#creates a button inside frame1
#self.button1.grid(row=0,column=1,padx=100,pady=4)
self.button3 = Button(frame1,text="Submit",command=self.printmessage)#creates a button inside frame1
self.button3.grid(row = 0,column = 2,padx = 100,pady = 4)
self.button4 = Button(frame1,text = "Quit",command = quit)#creates a button inside frame1
self.button4.grid(row = 0,column = 3,padx = 100,pady = 4)
def printmessage(self):
input = self.entertext.get("1.0",'end-1c')
file = open("input.txt","w")
file.write(input)
file.close()
nlist = returnwrong()
print nlist
c=0
var = [""]*20
for i in nlist:
wW = wrongWord(i, "big.txt")
wW.readDict()
wW.sortLen()
suggestions = wW.suggWords()
suggestions.append("Add")
print suggestions
#for j in suggestions:
# Button(frame1,text = j,command = replaceword(i,j)).pack()
var[c] = StringVar(frame1)
var[c].set(i) # initial value
option = apply(OptionMenu, (frame1, var[c]) + tuple(suggestions))
option.grid(row = 0, column = c)
c += 1
#button = Button(master, text="OK", command=ok)
#button.pack()
def confirm():
for i in range(c):
if(var[i].get()!="Add"):
replaceword(nlist[i], var[i].get())
else:
addtoDict(str(nlist[i]))
file = open("input.txt", "r")
text = file.read()
cwords = Label(frame2, text = text)
cwords.pack()
file.close()
ok = Button(frame1, text = "Confirm Changes", command = confirm)
ok.grid(row = 0, column = c)
frame2.quit()
search = searchtext(window)
window.title("Spell Checker")
file = open("input.txt")
text = file.read()
print text
file.close()
window.mainloop()