Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Gtk TextView insert text at end

I want to insert text to a textbuffer at the end... Im using this: gtk.TextBuffer.insert_at_cursor

But if I clicking into the text there the new appears at the cursor...

How can i add text at the end?

like image 797
Tekkzz Avatar asked Feb 15 '14 09:02

Tekkzz


1 Answers

Try using gtk.TextBuffer.insert() with gtk.TextBuffer.get_end_iter(). Example:

# text_buffer is a gtk.TextBuffer
end_iter = text_buffer.get_end_iter()
text_buffer.insert(end_iter, "The text to insert at the end")

NOTE: Once you insert into text_buffer, end_iter is invalidated so make sure to get a new reference to the end-iterator whenever you want to append to the end of the buffer.

like image 78
Uyghur Lives Matter Avatar answered Sep 18 '22 13:09

Uyghur Lives Matter