Python Gtk TextView末尾插入文本

Tek*_*kzz 8 python gtk textview gtk-textbuffer

我想在最后将文本插入文本缓冲区...我使用这个: gtk.TextBuffer.insert_at_cursor

但如果我点击文本,光标会出现新的...

我怎么能在最后添加文字?

use*_*450 10

尝试使用gtk.TextBuffer.insert()gtk.TextBuffer.get_end_iter().例:

# 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")
Run Code Online (Sandbox Code Playgroud)

注意:插入后text_buffer,end_iter会失效,因此每当要附加到缓冲区末尾时,请确保获得对end-iterator的新引用.