Apr-06-2020, 07:32 AM
I am attempting to find the correct way to put a search entry in a piece of code I have written. The entry widget would hold the input as a StringVar() that would be searched in a text widget and then highlight the word when found.
I have a reasonable idea of what I have to do and part of how I need to do it but I have not been able to get it to come together in a working form yet.
I have done some looking online for information and managed to find limited information and a couple of examples but I have not been able to make my search code work yet.
The text widget is Code_Snippet:
I have a reasonable idea of what I have to do and part of how I need to do it but I have not been able to get it to come together in a working form yet.
I have done some looking online for information and managed to find limited information and a couple of examples but I have not been able to make my search code work yet.
The text widget is Code_Snippet:
Code_Snippet = Text(root, bg = '#FFFFDF', fg='#000000', bd=0, width=117, height=27, relief=SUNKEN, cursor='hand2') Code_Snippet.place(x=19,y=58)The Entry widget is search_entry:
search_entry = Entry(root,bd = 2, textvariable = Search, width = '25', bg='#FAFAFA', cursor='hand2') search_entry.place(x=770,y=32)Search routine:
Search = StringVar() pos = Code_Snippet.search(Code_Snippet, "1.0", stopindex="end", count=Search) Code_Snippet.tag_configure('search', background="light blue") Code_Snippet.tag_add('search', pos, "%s + %sc" (pos, Search.get()I am having issues with this and could use some advice on how to correct the code so it will actually find the word and highlight it once it is found.
"Often stumped... But never defeated."