Jared Cohen wrote:

> I'm building a text editor that has an Undo/Redo feature. To do this, I 
> basically invoke a 
> callback every time the user presses a key; the callback copies the entire 
> contents of the Text 
> widget to a history list.

that's a bit more brute-force than it has to be; a better (but less
obvious) way is to "override" the insert and delete commands at
the widget implementation level.

see Lib/idlelib/Percolator.py for a helper class, and sample code
(the actual overriding is done in the WidgetRedirector.py module
in the same directory)

> Of course, the Text widget doesn't actually HAVE a method to explicitly
> set the position of the cursor

the cursor is represented by the INSERT mark, so

    text.mark_set(INSERT, position)

possibly followed by

    text.see(INSERT)

should do the trick.

</F> 



_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to