Hi all,

I'm trying to write a function that will highlight all occurances of the
string searchStr in the TextBuffer buffer. This is what I've currently got
that doesn't work.


def highlightText(buffer, searchStr):
    buffer.create_tag("red_foreground", foreground="red")
    start, end = buffer.get_bounds()
    finished = False

    while finished == False:
        res = start.forward_search(searchStr, gtk.TEXT_SEARCH_TEXT_ONLY)
        if not res:
            finished = True
        else:
            matchStart, matchEnd = res
            buffer.apply_tag_by_name("red_foreground", matchStart, matchEnd)
            start = matchStart


What's happening is that:

        res = start.forward_search(searchStr, gtk.TEXT_SEARCH_TEXT_ONLY)

is always returning None.  Any clues to what I'm doing wrong would be
appreciated, or a pointer to some other Pygtk code that does something
similar.

Thanks.

--
Rich Burridge                       Email:     [EMAIL PROTECTED]
Sun Microsystems Inc. (MPK14-260),  Phone:     +1.650.786.5188
4150 Network Circle,                AIM/YAHOO: RicBurridge
Santa Clara, CA 95054               Blog:      http://blogs.sun.com/richb
_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to