undo and redo ?

Discussion in 'Python' started by black, Jan 2, 2004.

  1. black

    black Guest

    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
    black, Jan 2, 2004
    #1
    1. Advertising

  2. > 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
    Diez B. Roggisch, Jan 2, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. black

    undo and redo

    black, Dec 23, 2003, in forum: Python
    Replies:
    0
    Views:
    347
    black
    Dec 23, 2003
  2. Robert Brewer

    RE: undo and redo ?

    Robert Brewer, Jan 2, 2004, in forum: Python
    Replies:
    0
    Views:
    346
    Robert Brewer
    Jan 2, 2004
  3. Jason Cavett
    Replies:
    0
    Views:
    311
    Jason Cavett
    Jun 15, 2007
  4. King
    Replies:
    0
    Views:
    312
  5. Replies:
    6
    Views:
    453
Loading...

Share This Page