472,353 Members | 1,818 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

Undo class

Hello everybody

I'm developing a tool in Tkinter and would like to add Undo and Redo
commands to my Edit menu. Does somebody know if anybody has implemented
standard Undo/Redo as a Python module? I could not find any info with
Google on the matter.

Cheers,

Mickel Grönroos

--
Mickel Grönroos, application specialist, linguistics, Research support,CSC
PL 405 (Tekniikantie 15 a D), 02101 Espoo, Finland, phone +358-9-4572237
CSC is the Finnish IT center for science, www.csc.fi

Jul 18 '05 #1
5 3643
Mickel Grönroos wrote:
Hello everybody

I'm developing a tool in Tkinter and would like to add Undo and Redo
commands to my Edit menu. Does somebody know if anybody has implemented
standard Undo/Redo as a Python module? I could not find any info with
Google on the matter.


On what king of widget? If it's a Text, you can use the native tk undo/redo
features: create the Text widget with the option undo set to 1, then use the
methods edit_undo() and edit_redo(). These are tk 8.4 features, so it may not
work for Python versions older than 2.3 (it doesn't work with 2.1; don't know
about 2.2)

For other widgets, I doubt there can be a generic mechanism to manage the
undo/redo functions for you: after all, only you can tell what actions should be
able to be undone or redone. But I'd be really happy if someone can prove me wrong!

HTH anyway.
--
- Eric Brunel <eric dot brunel at pragmadev dot com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com

Jul 18 '05 #2
In article <bo**********@news-reader3.wanadoo.fr>,
Eric Brunel <er*********@pragmadev.N0SP4M.com> wrote:
I'm developing a tool in Tkinter and would like to add Undo and Redo
commands to my Edit menu. Does somebody know if anybody has implemented
standard Undo/Redo as a Python module? I could not find any info with
Google on the matter.


On what king of widget? If it's a Text, you can use the native tk undo/redo
features: create the Text widget with the option undo set to 1, then use the
methods edit_undo() and edit_redo(). These are tk 8.4 features, so it may not
work for Python versions older than 2.3 (it doesn't work with 2.1; don't know
about 2.2)

For other widgets, I doubt there can be a generic mechanism to manage the
undo/redo functions for you: after all, only you can tell what actions should
be
able to be undone or redone. But I'd be really happy if someone can prove me
wrong!


The "only you can tell" argument is not convincing -- if you can tell,
you can tell it to the undo manager.

Take a look at the Cocoa UndoManager functionality.
Basically, while you're handle a change to a UI object, you call
U = undoManager.prepareWithInvocationTarget(self)
U.methods(arguments...)
where self.methods(arguments...) would be the calls you'd do
to reverse the change, and it saves the method names and arguments for
you. Later, when an undo is requested, it performs the calls you
prototyped for it. Very convenient, shouldn't be too hard to program in
Python directly (in fact it is available in Python on OS X now, via
PyObj).

--
David Eppstein http://www.ics.uci.edu/~eppstein/
Univ. of California, Irvine, School of Information & Computer Science
Jul 18 '05 #3
David Eppstein <ep******@ics.uci.edu> writes:
In article <bo**********@news-reader3.wanadoo.fr>,
Eric Brunel <er*********@pragmadev.N0SP4M.com> wrote:
I'm developing a tool in Tkinter and would like to add Undo and Redo
commands to my Edit menu. Does somebody know if anybody has implemented
standard Undo/Redo as a Python module? I could not find any info with
[...] Take a look at the Cocoa UndoManager functionality.
Basically, while you're handle a change to a UI object, you call
U = undoManager.prepareWithInvocationTarget(self)
U.methods(arguments...)
where self.methods(arguments...) would be the calls you'd do
to reverse the change, and it saves the method names and arguments for
you. Later, when an undo is requested, it performs the calls you
prototyped for it. Very convenient, shouldn't be too hard to program in
Python directly (in fact it is available in Python on OS X now, via
PyObj).

[...]

Another Undo API that does things in just the same way (pure Python,
with docs!):

http://sketch.sourceforge.net/Doc/devguide-19.html
While you're at it, you could do a lot worse than pinching his GUI
component publisher / subscriber code.
John
Jul 18 '05 #4
On Mon, 10 Nov 2003, Eric Brunel wrote:
For other widgets, I doubt there can be a generic mechanism to manage
the undo/redo functions for you: after all, only you can tell what
actions should be able to be undone or redone. But I'd be really happy
if someone can prove me wrong!


I need to undo some complex actions involving several steps, not only
entries in Text widgets. I'll take a look at UndoManager and Sketch as
suggested by David Eppstein and John Lee. Basically, I would like to have
a stack of undo commands that I can push to and pop from. I reckon this is
what UndoManager and Sketch does. I'll have a look. Thanks for the
pointers!

/Mickel

--
Mickel Grönroos, application specialist, linguistics, Research support,CSC
PL 405 (Tekniikantie 15 a D), 02101 Espoo, Finland, phone +358-9-4572237
CSC is the Finnish IT center for science, www.csc.fi

Jul 18 '05 #5
I have seen a 'transaction manager' for 'undo/redo' mechanism in SMW
http://www.abo.fi/~iporres/html/download.html

Look in smw/metamodel/TransactionManager.py.

Regards
Fabrice Clement

p.s.: sorry for my bad english !
Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: black | last post by:
I'm coding with Tkinter and i wonder whether we could get current OS' clipboard available, and event more, anyone can inspires me how we can achieve...
2
by: Tony Nelson | last post by:
I'm looking for a "pythonic" GTK Undo library/class. It would have a framework for Undo/Redo, and would provide Undo/Redo for TextView, Entry, and...
0
by: Wiktor Zychla | last post by:
I am still trying to get the Undo function work on Internet Explorer editor hosted as activex in my c# application. Some time ago I've found a...
2
by: Christian H | last post by:
Hello, I've tried to find information about how to implement an Undo/Redo pattern. This article describes such a pattern:...
10
by: John Richardson | last post by:
General question about how WinForms handles undoing a change during a control's validation, if it does at all. After a change to a control's value,...
3
by: GoogleEyeJoe | last post by:
Dear ladies and gents, I'm trying to determine whether the .NET Framework implements a means of transactional processing without the need for a...
4
by: =?Utf-8?B?UmljaA==?= | last post by:
Hello, Does vb2005 have a built-in UnDo feature / object for applications so that I can undo actions like other windows apps? Or do I have to...
7
by: call_me_anything | last post by:
Hi, I am looking for a good algorithm (in C/C++) for implementing undo/ redo on a data structure. The data structure is basically a n-children...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.