[Python] How to auto-scroll a gtk.scrolledwindow?

Discussão em 'Python' iniciado por Stack, Julho 8, 2025.

  1. Stack

    Stack Membro Participativo

    I have a treeview-widget inside a ScrolledWindow, which is populated during runtime. I want the ScrolledWindow to auto-scroll to the end of the list. I "solved" the problem, by adjusting the vadjustment of the ScrolledWindow, everytime a row is inserted into the treeview. e.g:

    if new_line_in_row:
    adj = self.scrolled_window.get_vadjustment()
    adj.set_value( adj.upper - adj.page_size )


    If i run the code in an interactive ipython session and set the value by myself, everything works as expected.

    If i run the code with the default python interpreter, the auto-scroll doesn't work all the time. I debugged the code and the problem seems be, that the adjustment values have some kind of "lag" and are only changed after some period of time.

    My question is: how do I scroll, reliably, to maximum position of the ScrolledWindow? is a special signal generated which i can use? or is there a better way to set the adjustment-value?

    Continue reading...

Compartilhe esta Página