[英]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
我想在结尾处向文本缓冲区插入文本...我使用这个:
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? 我怎么能在最后添加文字?
Try using gtk.TextBuffer.insert()
with gtk.TextBuffer.get_end_iter()
. 尝试将
gtk.TextBuffer.insert()
与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. 注意:一旦插入到
text_buffer
, end_iter
就会失效,所以每当你想要附加到缓冲区的末尾时,一定要获得对end-iterator的新引用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.