Reputation: 25
I am making an application with gtk and python.
In the application I have a scroll window and inside of it I have a textview.
When I use set_text()
in the textbuffer the scroll bar scrolls to the top.
What I want is when I use set_text()
is that scroll bar will scroll to the bottom.
Or in other words I want to control the scroll bar to go to the bottom.
How can it be done?
Thanks for the help!
Upvotes: 0
Views: 1126
Reputation: 2525
I believe there are 2 ways.
set_text
gtk3-demo
app in Text Widget -> Automatic Scrolling
section. There are following lines:/* If we want to scroll to the end, including horizontal scrolling,
* then we just create a mark with right gravity at the end of the
* buffer. It will stay at the end unless explicitly moved with
* gtk_text_buffer_move_mark.
*/
gtk_text_buffer_create_mark (buffer, "end", &iter, FALSE);
And then:
/* Get "end" mark. It's located at the end of buffer because
* of right gravity
*/
mark = gtk_text_buffer_get_mark (buffer, "end");
gtk_text_buffer_get_iter_at_mark (buffer, &iter, mark);
/* and insert some text at its position, the iter will be
* revalidated after insertion to point to the end of inserted text
*/
// Extra code removed
/* Now scroll the end mark onscreen.
*/
gtk_text_view_scroll_mark_onscreen (textview, mark);
Upvotes: 1