473,890 Members | 1,193 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 3786
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
2456
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
2125
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 menu; simply connecting such an object to an "UndoableUIManager" would take care of the stock items...
0
1283
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 IOleCommandTarget interface to invoke this command.
2
13276
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 , and you want to use undo/redo on them?
10
4364
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 is good. If the user wants to revert to the original data, say by hitting ESC, does the form...
3
3172
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 made. For example, if I had a, let's say for sake of simplicity, a person class that had two...
4
1598
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 write an
7
5422
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
9978
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10812
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10922
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10462
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8016
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7169
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5848
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4676
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
3
3276
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.