[pygtk] Almost there? Inserting formatted text to TextBuffer..

2004-05-21 Thread Dennis Craven
Hello,

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
gtk.TextBuffer.

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
buffer.

Thanks,
~djc


___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] Almost there? Inserting formatted text to TextBuffer..

2004-05-21 Thread John Finlay

Dennis Craven wrote:
Hello,
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
gtk.TextBuffer.
 

I don't believe this can work because the characters are not in the 
buffer when the signal is sent.

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
buffer.
 

You should ask how to do this on one of the GTK mail lists.
http://www.gtk.org/mailinglists.html
John
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/