Package qubx :: Module undo :: Class UndoStack
[hide private]
[frames] | no frames]

Class UndoStack

source code

object --+
         |
        UndoStack

Stack of undo and redo actions.

An action consists of one or more callables (no arguments). When the user does something, you push one or more pairs of functions that undo and redo it, then seal the action with a label. So, the top of the stack should be a seal (label), and "undo" reverses all actions between the top seal and the next one down.

>>> def Undo():
...     print "undo"
>>> def Redo():
...     print "redo"
>>> undos = UndoStack()
>>> undos.push_undo(Undo, Redo)
>>> undos.seal_undo('bogus test')
>>> undos.undo()
>>> undos.redo()
Instance Methods [hide private]
 
__init__(self, depth=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
clear(self)
Resets the stack so there are no undo or redo actions.
source code
 
enable(self, enabled=True) source code
 
get_can_undo(self) source code
 
get_undo_lbl(self) source code
 
get_can_redo(self) source code
 
get_redo_lbl(self) source code
 
push_undo(self, undo, redo)
Adds undo() and redo() to the stack.
source code
 
seal_undo(self, lbl)
Groups the preceding calls to push_undo(), sets undo_lbl, clears the redo stack.
source code
 
push_redo(self, redo, undo) source code
 
seal_redo(self, lbl) source code
 
undo(self, single_item=False)
Calls all unsealed undo functions, and all between the last two seal_undo()s, and transfers them to the redo stack.
source code
 
redo(self)
Does whatever was undone by undo(), transfers it back to the undo stack.
source code
 
add_check_depth(self) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables [hide private]
  can_undo
True if there is an undo action
  undo_lbl
string describing the undo action
  can_redo
True if there is a redo action
  redo_lbl
string describing the redo action
Properties [hide private]
  OnChange
  _depth
  _depth0
  _enabled
  _working
  rr
  uu

Inherited from object: __class__

Method Details [hide private]

__init__(self, depth=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

Instance Variable Details [hide private]

can_undo

True if there is an undo action
Get Method:
get_can_undo(self)

undo_lbl

string describing the undo action
Get Method:
get_undo_lbl(self)

can_redo

True if there is a redo action
Get Method:
get_can_redo(self)

redo_lbl

string describing the redo action
Get Method:
get_redo_lbl(self)