[Tkinter-discuss] Re: Problem with Text widget's "see" method

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Fri Feb 18 12:27:45 CET 2005

Martin Franklin wrote:
> Jared Cohen wrote:
>>> I see you got lots of help on the 'see' problem I just wanted to 
>>> point out the Text widget comes with it's own undo/redo methods as of 
>>> Tk 8.4
>>> so if you have an up to date Python & Tk you should be able to use them
>> Thanks anyway, but the undo doesn't seem to work. It's weird, because 
>> there IS an edit_undo() method in Tkinter.py (the Python wrapper), but 
>> apparently, the underlying Tk doesn't understand the command. Oh well.
> I guess your Tk version is not >= 8.4 thats too bad.
>> Anyway, I still need some help with this "see" problem. Come on guys, 
>> isn't there a way to fix this?
> I have tried a couple of things but it boils down to the fact you are
> replacing all the text in the widget, it just has to move (without the
> see call it moves the viewpoint to the top of the text widget)  If I
> were you I would investigate the IDLE undo / redo stuff Fredrik pointed
> you to, it undoes / redoes just the small changes (not the entire
> document)  I must admit *I* looked into that code when I needed undo /
> redo in a small project, I couldn't quite grok the code, eventually the
> need went away, but it would be nice if we could use the undo/redo from
> idlelib on *any* Tkinter Text widget - I seem to remember when I was
> looking at it it had a lot of idle dependencies... you couldn't just,
> for example:
> undoer = idlelib.Undoer(myTextWidget) # or whatever it's called
> and have it look after the undo and redo 'ing of your text widget
> would be nice if we could though;-)

And it seems (after a little more investigation) we can...

from Tkinter import Tk, Text

from idlelib.Percolator import Percolator
from idlelib.UndoDelegator import UndoDelegator
root= Tk()

text = Text(root)

per = Percolator(text)
undo = UndoDelegator()

text.bind("<F1>", undo.undo_event)
text.bind("<F2>", undo.redo_event)


*Seems to work* but has only been tested for 1 minute....


More information about the Tkinter-discuss mailing list