[pygtk] Almost there? Inserting formatted text to TextBuffer..
arker at rogers.com
Fri May 21 21:15:38 WST 2004
I've still not given up on inserting formatted text into a buffer on the
fly. This is the code I have at the moment. It is a function called each
time the user presses an input key, by the "insert-text" event.
def on_text_inserted(self, buffer, iter, text, length, data=None):
start = iter.copy()
end = iter.copy()
for tag in self.tag_list:
self.apply_tag(tag, start, end)
Where tag_list is a list of gtk.TextTags. This code produces no
formatting at all when there are tags in the list. If I move the "start"
iter back one position (backward_char()), then the second last character
in the buffer is formatted. I cannot move the "end" iter forward at all
(end.forward_char() returns FALSE). In this case, self is a
This almost works, but it doesn't. Has anyone got any suggestions? It
seems I cannot get two iters to surround the last character in the
More information about the pygtk