473,586 Members | 2,639 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3768
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**********@n ews-reader3.wanadoo .fr>,
Eric Brunel <er*********@pr agmadev.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.pre pareWithInvocat ionTarget(self)
U.methods(argum ents...)
where self.methods(ar guments...) 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.u ci.edu> writes:
In article <bo**********@n ews-reader3.wanadoo .fr>,
Eric Brunel <er*********@pr agmadev.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.pre pareWithInvocat ionTarget(self)
U.methods(argum ents...)
where self.methods(ar guments...) 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/TransactionMana ger.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
2440
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 undo and redo function ? thanx~ --------------------------------- Do you Yahoo!? Free Pop-Up Blocker - Get it now
2
2110
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 containers and other classes. In a "batteries included" fashion, just instantiating a "UndoableTextView" or "UndoableEntry" or "UndoableContainer" would provide Undo and Redo in the right-click...
0
1263
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 note at msdn that says "undo is not supported". I gave up. But lately I've downloaded LutzRoeder Writer that makes use of undo function. I've looked at the code and it turns out that it uses...
2
13260
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: http://www.codeproject.com/csharp/PcObjectUndo.asp , but is a little bit to narrow, since it only can handle 1 object, and since it only works on properties. What if you , in an application, have more than 1 object ,...
10
4325
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, if the data is determined to be invalid, then in the control's Validating event handler, setting e.Cancel = true will prevent the offending control from losing focus until the data in the control...
3
3149
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 database. Essentially, I'd like to enlist light-weight portable business objects within transactions so that that have the ability to roll-back if the client of the object wishes to undo any changes...
4
1583
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 write my own UnDo routine? If vb2005 does have a builtin Undo feature / object / command -- how to implement it? invoke it? If there is no builtin undo feature - is there a recommended way to...
7
5400
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 tree somewhat of the form : class /* or struct */ node { char *info1;
0
7912
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8202
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8216
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.