<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<big>Sorry, I forgot to include the previous message text:</big><br>
<blockquote type="cite">
  <pre>Martin Franklin wrote:
&gt;<i> Jared Cohen wrote:
</i>&gt;<i> 
</i>&gt;&gt;&gt;<i>
</i>&gt;&gt;&gt;<i>
</i>&gt;&gt;&gt;<i> I see you got lots of help on the 'see' problem I just wanted to 
</i>&gt;&gt;&gt;<i> point out the Text widget comes with it's own undo/redo methods as of 
</i>&gt;&gt;&gt;<i> Tk 8.4
</i>&gt;&gt;&gt;<i> so if you have an up to date Python &amp; Tk you should be able to use them
</i>&gt;&gt;&gt;<i>
</i>&gt;&gt;<i>
</i>&gt;&gt;<i> Thanks anyway, but the undo doesn't seem to work. It's weird, because 
</i>&gt;&gt;<i> there IS an edit_undo() method in Tkinter.py (the Python wrapper), but 
</i>&gt;&gt;<i> apparently, the underlying Tk doesn't understand the command. Oh well.
</i>&gt;<i> 
</i>&gt;<i> 
</i>&gt;<i> I guess your Tk version is not &gt;= 8.4 thats too bad.
</i>&gt;<i> 
</i>&gt;&gt;<i>
</i>&gt;&gt;<i> Anyway, I still need some help with this "see" problem. Come on guys, 
</i>&gt;&gt;<i> isn't there a way to fix this?
</i>&gt;&gt;<i>
</i>&gt;&gt;<i>
</i>&gt;<i> 
</i>&gt;<i> I have tried a couple of things but it boils down to the fact you are
</i>&gt;<i> replacing all the text in the widget, it just has to move (without the
</i>&gt;<i> see call it moves the viewpoint to the top of the text widget)  If I
</i>&gt;<i> were you I would investigate the IDLE undo / redo stuff Fredrik pointed
</i>&gt;<i> you to, it undoes / redoes just the small changes (not the entire
</i>&gt;<i> document)  I must admit *I* looked into that code when I needed undo /
</i>&gt;<i> redo in a small project, I couldn't quite grok the code, eventually the
</i>&gt;<i> need went away, but it would be nice if we could use the undo/redo from
</i>&gt;<i> idlelib on *any* Tkinter Text widget - I seem to remember when I was
</i>&gt;<i> looking at it it had a lot of idle dependencies... you couldn't just,
</i>&gt;<i> for example:
</i>&gt;<i> 
</i>&gt;<i> undoer = idlelib.Undoer(myTextWidget) # or whatever it's called
</i>&gt;<i> 
</i>&gt;<i> and have it look after the undo and redo 'ing of your text widget
</i>&gt;<i> would be nice if we could though;-)
</i>
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)
text.pack()

per = Percolator(text)
undo = UndoDelegator()
per.insertfilter(undo)

text.bind("&lt;F1&gt;", undo.undo_event)
text.bind("&lt;F2&gt;", undo.redo_event)

root.mainloop()

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

Cheers,
Martin.





  </pre>
<!--endarticle-->
  <hr><!--threads--> Previous message: </blockquote>
</body>
</html>