wx.CommandProcessor¶
wx.CommandProcessor is a class that maintains a history of Commands, with undo/redo functionality built-in.
Derive a new class from this if you want different behaviour.
See also
Class Hierarchy¶
Methods Summary¶
Constructor. |
|
Returns |
|
Returns |
|
Deletes all commands in the list and sets the current command pointer to |
|
Returns the list of commands. |
|
Returns the current command. |
|
Returns the edit menu associated with the command processor. |
|
Returns the maximum number of commands that the command processor stores. |
|
Returns the string that will be appended to the Redo menu item. |
|
Returns the string that will be shown for the redo menu item. |
|
Returns the string that will be appended to the Undo menu item. |
|
Returns the string that will be shown for the undo menu item. |
|
Initializes the command processor, setting the current command to the last in the list (if any), and updating the edit menu (if one has been specified). |
|
Returns a boolean value that indicates if changes have been made since the last save operation. |
|
You must call this method whenever the project is saved if you plan to use |
|
Executes (redoes) the current command (the command that has just been undone if any). |
|
Tells the command processor to update the Undo and Redo items on this menu as appropriate. |
|
Sets the menu labels according to the currently set menu and the current command state. |
|
Sets the string that will be appended to the Redo menu item. |
|
Sets the string that will be appended to the Undo menu item. |
|
Just store the command without executing it. |
|
Submits a new command to the command processor. |
|
Undoes the last command executed. |
Properties Summary¶
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
Class API¶
- class wx.CommandProcessor(Object)¶
Possible constructors:
CommandProcessor(maxCommands=-1) -> None
CommandProcessor is a class that maintains a history of Commands, with undo/redo functionality built-in.
Methods¶
- __init__(self, maxCommands=-1)¶
Constructor.
- Parameters:
maxCommands (int) – May be set to a positive integer to limit the number of commands stored to it, otherwise (and by default) the list of commands can grow arbitrarily.
- Return type:
None
- CanRedo(self)¶
Returns
True
if the currently-active command can be redone,False
otherwise.- Return type:
bool
- CanUndo(self)¶
Returns
True
if the currently-active command can be undone,False
otherwise.- Return type:
bool
- ClearCommands(self)¶
Deletes all commands in the list and sets the current command pointer to
None
.- Return type:
None
- GetCommands(self)¶
Returns the list of commands.
- Return type:
CommandList
- GetCurrentCommand(self)¶
Returns the current command.
- Return type:
- GetEditMenu(self)¶
Returns the edit menu associated with the command processor.
- Return type:
- GetMaxCommands(self)¶
Returns the maximum number of commands that the command processor stores.
- Return type:
int
- GetRedoAccelerator(self)¶
Returns the string that will be appended to the Redo menu item.
- Return type:
str
- GetRedoMenuLabel(self)¶
Returns the string that will be shown for the redo menu item.
- Return type:
str
- GetUndoAccelerator(self)¶
Returns the string that will be appended to the Undo menu item.
- Return type:
str
- GetUndoMenuLabel(self)¶
Returns the string that will be shown for the undo menu item.
- Return type:
str
- Initialize(self)¶
Initializes the command processor, setting the current command to the last in the list (if any), and updating the edit menu (if one has been specified).
- Return type:
None
- IsDirty(self)¶
Returns a boolean value that indicates if changes have been made since the last save operation.
This only works if
MarkAsSaved
is called whenever the project is saved.- Return type:
bool
- MarkAsSaved(self)¶
You must call this method whenever the project is saved if you plan to use
IsDirty
.- Return type:
None
- Redo(self)¶
Executes (redoes) the current command (the command that has just been undone if any).
- Return type:
bool
- SetEditMenu(self, menu)¶
Tells the command processor to update the Undo and Redo items on this menu as appropriate.
Set this to
None
if the menu is about to be destroyed and command operations may still be performed, or the command processor may try to access an invalid pointer.- Parameters:
menu (wx.Menu)
- Return type:
None
- SetMenuStrings(self)¶
Sets the menu labels according to the currently set menu and the current command state.
- Return type:
None
- SetRedoAccelerator(self, accel)¶
Sets the string that will be appended to the Redo menu item.
- Parameters:
accel (string)
- Return type:
None
- SetUndoAccelerator(self, accel)¶
Sets the string that will be appended to the Undo menu item.
- Parameters:
accel (string)
- Return type:
None
- Store(self, command)¶
Just store the command without executing it.
The command is stored in the history list, and the associated edit menu (if any) updated appropriately.
- Parameters:
command (wx.Command)
- Return type:
None
- Submit(self, command, storeIt=True)¶
Submits a new command to the command processor.
The command processor calls
wx.Command.Do
to execute the command; if it succeeds, the command is stored in the history list, and the associated edit menu (if any) updated appropriately. If it fails, the command is deleted immediately. OnceSubmit
has been called, the passed command should not be deleted directly by the application.- Parameters:
command (wx.Command) – The command to submit
storeIt (bool) – Indicates whether the successful command should be stored in the history list.
- Return type:
bool
- Undo(self)¶
Undoes the last command executed.
- Return type:
bool
Properties¶
- Commands¶
See
GetCommands
- CurrentCommand¶
- EditMenu¶
See
GetEditMenu
andSetEditMenu
- MaxCommands¶
See
GetMaxCommands
- RedoAccelerator¶
See
GetRedoAccelerator
andSetRedoAccelerator
- RedoMenuLabel¶
See
GetRedoMenuLabel
- UndoAccelerator¶
See
GetUndoAccelerator
andSetUndoAccelerator
- UndoMenuLabel¶
See
GetUndoMenuLabel