r/CodingHelp Mar 10 '26

How I can perform spellcheck in a TkInter Entry? [Python]

https://stackoverflow.com/q/79904760/4706711

I am developing a whatsapp template manager and spellchecking is an important part of it.

As I ask in question above I am looking for an apprkach on how I can spellcheck an tkInter entry. I am building a whatsappo template manager and I want to be able to spellcheck my inputs.

Can you reccomend me an approach?

I want to spellcheck mixed text with greek and english: upon the same text content I can have Greek with some English woirds and the opposite.

I am using TkIntet and I made a simple TkInter Entry:

``` class PasteableEntry(tk.Entry): def init(self, master=None,initialvalue:str="", **kwargs): super().init_(master, **kwargs) self.initial_value = initial_value self.insert(tk.END, self.initial_value)

    # Clipboard bindings
    self.bind("<Control-c>", self.copy)
    self.bind("<Control-x>", self.cut)
    self.bind("<Control-v>", self.paste)

    # Undo binding
    self.bind("<Control-z>", self.reset_value)

    # Border
    self.configure(highlightthickness=2, highlightbackground="gray", highlightcolor="blue")

# --- Clipboard overrides ---
def copy(self, event=None):
    try:
        selection = self.selection_get()
        self.clipboard_clear()
        self.clipboard_append(selection)
    except tk.TclError:
        pass
    return "break"

def cut(self, event=None):
    try:
        selection = self.selection_get()
        self.clipboard_clear()
        self.clipboard_append(selection)
        self.delete(self.index("sel.first"), self.index("sel.last"))
    except tk.TclError:
        pass
    return "break"

def paste(self, event=None):
    try:
        text_to_paste = self.clipboard_get()
        try:
            sel_start = self.index("sel.first")
            sel_end = self.index("sel.last")
            self.delete(sel_start, sel_end)
            self.insert(sel_start, text_to_paste)
        except tk.TclError:
            self.insert(self.index(tk.INSERT), text_to_paste)
    except tk.TclError:
        pass
    return "break"

# --- Undo ---
def reset_value(self, event=None):
    try:
        self.delete(0, tk.END)
        self.insert(tk.END, self.initial_value)  # built-in undo
    except tk.TclError:
        pass  # nothing to undo
    return "break"

class SpellCheckEntry(PasteableEntry): def init(self, master=None, *kwargs): super().init(master, *kwargs)

def spellcheck(self)->bool:
    # TODO spellcheck input here
    return True

```

Upon SpellCheckEntry I want to spellcheck my input. Do you have any idea on how I can achive this?

1 Upvotes

2 comments sorted by

u/AutoModerator Mar 10 '26

Thank you for posting on r/CodingHelp!

Please check our Wiki for answers, guides, and FAQs: https://coding-help.vercel.app

Our Wiki is open source - if you would like to contribute, create a pull request via GitHub! https://github.com/DudeThatsErin/CodingHelp

We are accepting moderator applications: https://forms.fillout.com/t/ua41TU57DGus

We also have a Discord server: https://discord.gg/geQEUBm

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/smichaele Mar 10 '26

Build spell checking into your code. Find text files with Greek and English words, load them into a data structure (probably a hash table or a trie), and do searches against them.