traitsui.undo module

Defines the manager for Undo and Redo history for Traits user interface support.

class traitsui.undo.AbstractUndoItem[source]

Bases: AbstractCommand

Abstract base class for undo items.

This class is deprecated and will be removed in TraitsUI 8. Any custom subclasses of this class should either subclass from AbstractCommand, or provide the ICommand interface.

do()[source]

Does nothing.

All undo items log events after they have happened, so by default they do not do anything when added to the history.

merge(other)[source]

Merges two undo items if possible.

name = "Edit"

A simple default name.

redo()[source]

Re-does the change.

undo()[source]

Undoes the change.

class traitsui.undo.ListUndoItem[source]

Bases: AbstractUndoItem

A change to a list, which can be undone.

added = List()

Items added to the list

index = Int()

Starting index

merge(undo_item)[source]

Merges two undo items if possible.

name = Str()

Name of the trait that changed

object = Instance(HasTraits)

Object that the change occurred on

redo()[source]

Re-does the change.

removed = List()

Items removed from the list

undo()[source]

Undoes the change.

class traitsui.undo.UndoHistory[source]

Bases: HasStrictTraits

Manages a list of undoable changes.

add(undo_item, extend=False)[source]

Adds an UndoItem to the history.

can_redo = Property(Bool, observe='_can_redo')

Can an action be redone?

can_undo = Property(Bool, observe='_can_undo')

Can an action be undone?

clear()[source]

Clears the undo history.

extend(undo_item)[source]

Extends the undo history.

If possible the method merges the new UndoItem with the last item in the history; otherwise, it appends the new item.

manager = Instance(IUndoManager, allow_none=False)

The undo manager for the history.

now = Property(Int, observe='stack._index')

The current position in the list

redo()[source]

Redoes an operation.

redoable = Event(False)

Fired when state changes to redoable

revert()[source]

Reverts all changes made so far and clears the history.

stack = Instance(ICommandStack, allow_none=False)

The command stack for the history.

undo()[source]

Undoes an operation.

undoable = Event(False)

Fired when state changes to undoable

class traitsui.undo.UndoHistoryUndoItem[source]

Bases: AbstractUndoItem

An undo item for the undo history.

history = Instance(UndoHistory)

The undo history to undo or redo

redo()[source]

Re-does the change.

undo()[source]

Undoes the change.

class traitsui.undo.UndoItem[source]

Bases: AbstractUndoItem

A change to an object trait, which can be undone.

merge(undo_item)[source]

Merges two undo items if possible.

name = Str()

Name of the trait that changed

new_value = Property()

New value of the changed trait

object = Instance(HasTraits)

Object the change occurred on

old_value = Property()

Old value of the changed trait

redo()[source]

Re-does the change.

undo()[source]

Undoes the change.