[Tkinter-discuss] Restoring scroll position in a scrolled text window

Michael Lange klappnase at web.de
Tue Mar 16 21:03:07 CET 2010


Hi Mick,

On Tue, 16 Mar 2010 18:22:00 +0100
"Michael O'Donnell" <michael.odonnell at uam.es> wrote:

> Hi all,
> 
>   Under Windows with python 2.6.4 Tkinter 8.5
> 
>   I am trying to find a way to restore exactly the same scroll
> position in a scrolled text widget, after deleting all text and
> re-inserting the same text.
> 

I think it should work like this:

>>> from ScrolledText import ScrolledText
>>> s=ScrolledText()
>>> s.pack(fill='both', expand=1)
>>> s.insert('end', some_text)
>>> first, last = s.yview()
>>> s.delete(1.0, 'end')
>>> s.insert('end', some_text)
>>> s.yview_moveto(first)

I hope this helps

Michael



More information about the Tkinter-discuss mailing list