Home > front end >  How find whole words in tkinter text widget and not strings part of a word
How find whole words in tkinter text widget and not strings part of a word

Time:06-28

My present code -

def find():
    
    #remove tag 'found' from index 1 to END
    text.tag_remove('found', '1.0', END)
    
    #returns to widget currently in focus
    s = edit.get()
    if s:
        idx = '1.0'
        while 1:
            #searches for desired string from index 1
            idx = text.search(s, idx, nocase=1,
                            stopindex=END)
            if not idx: break
            
            #last index sum of current index and
            #length of text
            lastidx = '%s            
  • Related