From 70e1163519ac2a73f07b1f5da7e14fda426271f2 Mon Sep 17 00:00:00 2001 From: "(Tim) Efthimis Kritikos" Date: Sat, 23 Aug 2025 14:14:10 +0100 Subject: [PATCH] Added a very primative spell check function --- metadata_writer.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/metadata_writer.py b/metadata_writer.py index de791fb..46117c6 100755 --- a/metadata_writer.py +++ b/metadata_writer.py @@ -23,6 +23,8 @@ #Add timezone setting for exif date #Change the background of TitledFrames from the wnidow background #Add spellcheck in texts +#Make computasionally heavy processes like searching for a point in gpx file in a sepparate thread asynchronously +#remove reference to GPS and fix gnss/gpx wording in codebase and json output #import stuff that's needed for both GUI and check mode plus tkinter to make inheritance easier (for now) import sys @@ -57,6 +59,10 @@ def main(): from fractions import Fraction import gpxpy import gpxpy.gpx + import nltk + from nltk.corpus import words + + nltk.download('words') device_data = { "lights": [ { "id": 0, "brand":"", "name": "other" }, @@ -240,6 +246,7 @@ def main(): def update_texts(*args): data["texts"]["title"]=title.get() data["texts"]["description"]=description.get("1.0",'end-1c') + description.spell_check(words) texts_frame=TitledFrame(editables,[("[1]", ("TkDefaultFont", 12, "bold")),("Texts", ("TkDefaultFont", 10))]) @@ -614,8 +621,17 @@ class TextScrollCombo(tk.Frame): scrollb.grid(row=1, column=1, sticky='nsew') self.txt['yscrollcommand'] = scrollb.set - def get(c,a,b): - return c.txt.get(a,b) + def get(self,a,b): + return self.txt.get(a,b) + def spell_check(self,words): + content=self.txt.get("1.0",'end-1c') + for tag in self.txt.tag_names(): + self.txt.tag_delete(tag) + for word in content.split(' '): + if word.lower() not in words.words(): + position = content.find(word) + self.txt.tag_add(word, f'1.{position}', f'1.{position + len(word)}') + self.txt.tag_config(word, underline=True, underlinefg='red') class TitledDropdown(tk.Frame):