Python Forum
tkinter search box
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tkinter search box
#1
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:
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."
Reply


Messages In This Thread
tkinter search box - by DT2000 - Apr-06-2020, 07:32 AM
RE: tkinter search box - by joe_momma - Apr-06-2020, 03:34 PM
RE: tkinter search box - by joe_momma - Apr-06-2020, 11:18 PM
RE: tkinter search box - by DT2000 - Apr-08-2020, 05:59 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [Tkinter] Search data in treeview without search button TomasSanchexx 3 1,526 Aug-12-2023, 03:17 AM
Last Post: deanhystad
  [Tkinter] add search bar = search for input in all computer directory francisco_neves2020 15 10,760 Apr-14-2019, 07:29 PM
Last Post: francisco_neves2020
  [Tkinter] Problem with tkinter search widget poopcupine 1 2,641 Mar-25-2019, 08:24 AM
Last Post: Larz60+
  Python, Tkinter. How to search a specific file in a folder Roo 3 3,386 Feb-13-2019, 10:41 AM
Last Post: Larz60+
  [Tkinter] THow to search a string in a file and display it in listbox by Tkinter mosavit 2 5,605 Jun-21-2017, 08:02 AM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020