Hello so I'm trying to figure out how to make a find function in tkinter. I did figure out how to get tkinter to highlight a specifically searched text there is a few issues I'm having though. Lets say they have the word at line 3 it will highlight all the lines to line 3 so it will highlight line 1, 2, and all of line 3. I'm trying to figure out how to just get it to select the word. I also don't think I'm going about it the right way with highlighting it because they wouldn't be able to right click it and copy it so if anyone can help me I'd really apperciate it!
def find():
findString = simpledialog.askstring("Find...", "Enter text")
textData = notepad.get(0.0, END)
cannot = 'Can not find:'
find = findString
cannotfind = cannot + " " + find
if findString in textData:
notepad.tag_add(findString, 0.0, "END")
notepad.tag_config(findString, background="blue", foreground="white")
else:
messagebox.showinfo('Not Found!', cannotfind)
*edit I was thinking of instead of using (0.0, END) figuring out how to store the coordinates in a variable of the searched text that would solve all my problems but I don't know if its possible.