|
| 1 | +from tkinter import * |
| 2 | +from PIL import ImageTk, Image |
| 3 | +from textblob import TextBlob |
| 4 | + |
| 5 | +root = Tk() |
| 6 | +root.title("Spelling Corrector") |
| 7 | +root.iconbitmap(r"C:\Users\FUTURE LAPTOP\Downloads\bee_icon_177139.ico") |
| 8 | +root.geometry('500x500') |
| 9 | + |
| 10 | +img = ImageTk.PhotoImage(Image.open(r"C:\Users\FUTURE LAPTOP\Downloads\Spelling Corrector.png")) |
| 11 | +label = Label(root, image=img) |
| 12 | +label.place(relx=0.5, rely=0.12, anchor=CENTER) |
| 13 | + |
| 14 | +img2 = ImageTk.PhotoImage(Image.open(r"C:\Users\FUTURE LAPTOP\Downloads\Untitled design.png")) |
| 15 | +label2 = Label(root, image=img2) |
| 16 | +label2.place(relx=0.58, rely=0.82, anchor=W) |
| 17 | + |
| 18 | +my_frame = LabelFrame(root, text="Correct Spellings", font=("Roboto", 15), fg="#000000", padx=100, pady=10) |
| 19 | +my_frame.pack(padx=15, pady=150) |
| 20 | + |
| 21 | +Label(my_frame, text="Your Word: ", font=("Roboto", 15), padx=7, relief="groove").\ |
| 22 | + grid(row=0, column=0, columnspan=2, padx=2, pady=5, sticky="W") |
| 23 | + |
| 24 | +enter_word = Entry(my_frame, highlightthickness=2) |
| 25 | +enter_word.config(highlightbackground="#FFFF00", highlightcolor="#FFFF00") |
| 26 | +enter_word.grid(row=0, column=2, padx=2, pady=5, sticky="W") |
| 27 | + |
| 28 | + |
| 29 | +# Parsing the given string into individual characters. |
| 30 | +def parse_string(string): |
| 31 | + charc_list = list(string.split()) |
| 32 | + return charc_list |
| 33 | + |
| 34 | + |
| 35 | +def clicked(word): |
| 36 | + word_charc = parse_string(word) |
| 37 | + |
| 38 | + correct_word_charc = [] |
| 39 | + corrected = "" |
| 40 | + |
| 41 | + for i in word_charc: |
| 42 | + correct_word_charc.append(TextBlob(i)) |
| 43 | + |
| 44 | + for i in correct_word_charc: |
| 45 | + corrected = i.correct() |
| 46 | + |
| 47 | + Label(my_frame, text="Correct Word: ", font=("Roboto", 15), padx=7, relief="groove"). \ |
| 48 | + grid(row=2, column=0, columnspan=2, padx=2, pady=5, sticky="W") |
| 49 | + |
| 50 | + Label(my_frame, text=corrected, font=("Roboto", 15), padx=7, relief="groove"). \ |
| 51 | + grid(row=2, column=2, padx=2, pady=5, sticky="W") |
| 52 | + |
| 53 | + |
| 54 | +my_button = Button(my_frame, text="Enter", font=("Roboto", 13), width=7, padx=2, bg="#FFFF00", fg="#000000", |
| 55 | + command=lambda: clicked(enter_word.get())) |
| 56 | +my_button.grid(row=1, column=0, columnspan=2, padx=4, pady=5, sticky="W") |
| 57 | + |
| 58 | +root.mainloop() |
0 commit comments