Weirdness with Tkinter Text and Scroll widgets

Erik de Castro Lopo invalid at email.com
Wed May 16 11:24:39 EDT 2001


Hi there,

I'm working on a little app which redraws text in a Tkinter Text window. 
What I'd like to be able to do is the following: 

    # Get the current scroll bar poistion 
    position = scroll.get () 

    # Delete all text 
    text.delete (0.0, END) 

    # Insert the replacement text 
    text.insert (END, new_text) 
       
    # Set the scroll position back to where it was. 
    scroll.set (position [0], position [1]) 

The problem I'm having is that no matter what the position of the 
scrollbar before the call to scroll.get (), the scollbar is always 
returned to the top after the end of this section of code instead of 
returning to the original position. The length of text in the widget 
before and after this section of code is the same (and greater than 
the size of the text widget). 

Anybody have any idea why its doing this or better still, how to fix it? 

Thanks in advance.



More information about the Python-list mailing list