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