我想在最后将文本插入文本缓冲区...
我正在使用这个:gtk.TextBuffer.insert_at_cursor
但是,如果我点击文本,光标会出现新的颜色......
如何在最后添加文字?
答案 0 :(得分:8)
尝试将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")
注意:一旦插入text_buffer
,end_iter
就会失效,所以每当你想要附加到缓冲区的末尾时,一定要获得对end-iterator的新引用。