Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > undo and redo ?

Reply
Thread Tools

undo and redo ?

 
 
black
Guest
Posts: n/a
 
      01-02-2004
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
 
Reply With Quote
 
 
 
 
Diez B. Roggisch
Guest
Posts: n/a
 
      01-02-2004
> 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 ?


When working with a MVC-approach, the actions you the user can invoke on the
model could be created as objects that know how to undo/invert their
effects. Then you store a list of these actions and performing undo takes
the last action and apply its inverted action to your model. Right from my
head:

class InsertAction:
def __init__(_, index, needle):
_.index = index
_.needle = needle

def do(_, haystack):
haystack[index:index] = _.needle

def undo(_, haystack):
del haystack[_.index : _.index + len(_.needle)]


Hope this gives you an idea. You can also have to types of actions -
primitive and complex. Performing undo will then undo all primitve actions
until the action queue is empty or a complex actions is reached. This
allows e.g. in a text-editor to perform undo subsequently inserted
characters at once.

HTH,

Diez
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Undo-Redo, copy instance, custom events and a problem King Python 0 07-26-2010 05:32 AM
Undo/Redo, Subclasses and Lots of Listeners Jason Cavett Java 0 06-15-2007 08:26 PM
implementing undo and redo for textarea's - does Javascript support static variables? lkrubner@geocities.com Javascript 6 12-10-2004 09:51 PM
RE: undo and redo ? Robert Brewer Python 0 01-02-2004 06:31 PM
undo and redo black Python 0 12-23-2003 03:56 AM



Advertisments