[pygtk] Scrolling to the previous position in a TreeView

Lionel Dricot zeploum at gmail.com
Fri Jan 30 18:50:56 WST 2009


So it works with :

gobject.timeout_add(100,
self.task_tview.get_vadjustment().set_value,vscroll_value)

The problem is that the delay is very noticable ! You see the content
jumping up and down and it's really ugly. A smaller delay (10) doesn't work
at all. 50 works but I believe that it might not work everywhere.

On Fri, Jan 30, 2009 at 1:07 AM, Neil Dugan
<pygtk at butterflystitches.com.au>wrote:

> Lionel Dricot wrote:
>
>> Hello,
>>
>> I'm displaying a treeview in my application and I update the content by
>> creating a new treestore and then, once the treestore is create, I replace
>> the old one with set_model.
>>
>> Unfortunatly, the scroll position is not preserved and, at each refresh,
>> the
>> scroll go back to the top of the page.
>>
>> I thought that it would be as simple as :
>>
>> vadjust = self.treeview.get_vadjustment()
>> ...
>> refresh
>> ...
>> self.treeview.set_adjustement(vadjust)
>>
>> But it doesn't work at all.
>>
>> I've tried to set the value of vadjust, it has no effect.
>>
>> What is strange is that if at any point I do a
>> self.treeview.get_vadjustment().get_value(), I have the good value for the
>> scrolling ! So the adjustment is good.
>>
>> But then, why does my tree scroll to the top at each refresh ?
>>
>> Can anybody help me ? How do you do when you want to keep a scrolled
>> position ?
>>
>> Thanks,
>>
>> Lionel
>>
>>
>>
> Sometimes I find that a small delay helps.
>
> # untested code
> gobject.timeout_add(100,
> self.treeview.get_vadjustment().set_value(old_value))
>
> The users wont notice a 1/10 second delay.
>
> Regards Neil.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20090130/a56c959b/attachment.htm 


More information about the pygtk mailing list