Spell Corrector GUI using Tkinter in Python
GUI:
A graphical interface (GUI) is a user interface that lets users interact with electronic devices like computers and smartphones by using menus, icons, and other visual cues (graphics). In contrast to text-based interfaces, which only display data and commands as text, GUIs visualize information and related user controls. A cursor, trackball, stylus, or thumb on a touch screen are all pointing devices that can be used to communicate with GUI representations. The first text interface between a human and a computer operated using keyboard input and a prompt.
The user is provided with information using manipulable visual widgets that don't require command-line input. These interface components respond to the user's interactions per the pre-programmed script, assisting each user's action. Since many GUIs represent text and graphical elements in standard formats, it is possible for programs using the same GUI software to share data. As it is patched and developed, the same software application or os version may present distinct or marginally distinct GUIs. The appearance of an application may change depending on user needs or to enhance the user experience, even if the application's core functionality and functions remain unchanged, as was the case with the various Windows versions over time.
Tkinter:
The standard Python technique for building Graphical User Interfaces (GUIs) is Tkinter, which is included in all popular Python distributions. The only framework included in the Python standard library is this one. On top of Tk, this Python framework serves as a thin object-oriented layer that provides access to the Tk toolkit. The Tk toolkit is a cross-platform set of "graphical control elements," also called widgets, used to build application interfaces. This framework gives Python users a quick and easy way to build GUI elements with the Tk toolkit's widgets. In a Python application, Tk widgets can be used to create buttons, menus, data fields, etc.
Tkinter bridges the gap between Python's execution model and Tcl's, built around cooperative multitasking. Like Python, Tcl is an interpreted dynamic programming language. Although it is an overall programming language that can be used independently, it is most frequently used in C programs as a scripting motor or as an interaction with the Tk toolbox. The Tcl library has a C interface that enables users to add custom Tcl or C commands, run Tcl commands and scripts, and manage one or more Tcl interpreter instances. Each interpreter has a queue for events that can be used to send and process events.
Syntax:
from tkinter import *
from tkinter import ttk
Compound Interest:
The yearly interest rate is raised to the number of composite periods minus one, and the initial original investment is multiplied by both these factors. The resulting value is then deducted from the loan's total initial amount.
CODE:
from tkinter import *
from textblob import TextBlob
def clearAll() :
word1_field.delete(0, END)
word2_field.delete(0, END)
def correction() :
input_word = word1_field.get()
blob_obj = TextBlob(input_word)
corrected_word = str(blob_obj.correct())
word2_field.insert(10, corrected_word)
if __name__ == "__main__" :
root = Tk()
root.configure(background = 'light green')
root.geometry("400x150")
root.title("Spell Corrector")
headlabel = Label(root, text = 'Welcome to Spell Corrector Application',
fg = 'black', bg = "red")
label1 = Label(root, text = "Input Word",
fg = 'black', bg = 'dark green')
label2 = Label(root, text = "Corrected Word",
fg = 'black', bg = 'dark green')
headlabel.grid(row = 0, column = 1)
label1.grid(row = 1, column = 0)
label2.grid(row = 3, column = 0, padx = 10)
word1_field = Entry()
word2_field = Entry()
word1_field.grid(row = 1, column = 1, padx = 10, pady = 10)
word2_field.grid(row = 3, column = 1, padx = 10, pady = 10)
button1 = Button(root, text = "Correction", bg = "red", fg = "black",
command = correction)
button1.grid(row = 2, column = 1)
button2 = Button(root, text = "Clear", bg = "red",
fg = "black", command = clearAll)
button2.grid(row = 4, column = 1)
root.mainloop()
CODE EXPLANATION:
Importing the modules which are tkinter and textblob. Considering the input word with the keyword field.get() then passing the input to the textblob module to correct the incorrect input word then gives the output in an efficient way. We consider if the input is correct to the module of textblob it returns the same input in the output block if it needs any correction then it continues to work process.
OUTPUT:
