Regex and Tkinter

Jeffrey Dunnett jdunnett at uoguelph.ca
Fri Nov 16 16:26:40 CET 2001


What I am trying to do is implement a find, find next option on a 
Tkinter\Python program usings reg. expressions what I am not sure about 
how to do is how to A) Get the information location in the string where 
the regex was found B) Hightlight the text in the text box on scree.

So far I have a created text box with some text in it and am doing this

def findregegx(self):

    #Gets the regex from a entry widget created earlier in the class
    self.expression = self.regexp_entry.get()

    #Gets the text from the text field created earlier, self. index = 1.0
    self.search_text = self.display.articleArea.listbox.get(self.index, END)

    #Searching for the regex
    found = re.search(self.expression, self.search_text)

    print found.group()


I figure that I can hightlight the text by using tags in some way but I 
am not quite certain how to go about finding where the regext is in the 
text field.  Any help would be appreciated.

Jeff Dunnett




More information about the Python-list mailing list