1 2 3 4 5 6 7 8 9 10 11 12
|
vu dans la FAQ de pygtk
14.10. How do I scroll a TextView to display the text being inserted?
When inserting text using insert_at_custor(), it may happen that the text inserted surpasses the textview's current viewport, and requires scrolling.
Gustavo Carneiro and Mikoyan wrote in to suggest using the textbuffer's scroll_to_mark() method, which scrolls to a certain point in the buffer. You can use the get_insert() method to return the current insert position right after inserting if you want to make sure you scroll to the end of the text.
end_iter = text_buffer.get_end_iter()
text_buffer.insert(end_iter, text)
text_view.scroll_to_mark(text_buffer.get_insert(), 0)
There is also a simplier method to make sure the text view's cursor is visible:
text_view.scroll_mark_onscreen(text_buffer.get_insert()) |