phoenix_title 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.


class_hierarchy Class Hierarchy

Inheritance diagram for class CommandProcessor:

method_summary Methods Summary

__init__

Constructor.

CanRedo

Returns True if the currently-active command can be redone, False otherwise.

CanUndo

Returns True if the currently-active command can be undone, False otherwise.

ClearCommands

Deletes all commands in the list and sets the current command pointer to None.

GetCommands

Returns the list of commands.

GetCurrentCommand

Returns the current command.

GetEditMenu

Returns the edit menu associated with the command processor.

GetMaxCommands

Returns the maximum number of commands that the command processor stores.

GetRedoAccelerator

Returns the string that will be appended to the Redo menu item.

GetRedoMenuLabel

Returns the string that will be shown for the redo menu item.

GetUndoAccelerator

Returns the string that will be appended to the Undo menu item.

GetUndoMenuLabel

Returns the string that will be shown for the undo menu item.

Initialize

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).

IsDirty

Returns a boolean value that indicates if changes have been made since the last save operation.

MarkAsSaved

You must call this method whenever the project is saved if you plan to use IsDirty .

Redo

Executes (redoes) the current command (the command that has just been undone if any).

SetEditMenu

Tells the command processor to update the Undo and Redo items on this menu as appropriate.

SetMenuStrings

Sets the menu labels according to the currently set menu and the current command state.

SetRedoAccelerator

Sets the string that will be appended to the Redo menu item.

SetUndoAccelerator

Sets the string that will be appended to the Undo menu item.

Store

Just store the command without executing it.

Submit

Submits a new command to the command processor.

Undo

Undoes the last command executed.


api Class API

class wx.CommandProcessor(Object)

Possible constructors:

CommandProcessor(maxCommands=-1)

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.



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.



GetCommands(self)

Returns the list of commands.

Return type

CommandList



GetCurrentCommand(self)

Returns the current command.

Return type

wx.Command



GetEditMenu(self)

Returns the edit menu associated with the command processor.

Return type

wx.Menu



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

string



GetRedoMenuLabel(self)

Returns the string that will be shown for the redo menu item.

Return type

string



GetUndoAccelerator(self)

Returns the string that will be appended to the Undo menu item.

Return type

string



GetUndoMenuLabel(self)

Returns the string that will be shown for the undo menu item.

Return type

string



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).



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 .



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) –



SetMenuStrings(self)

Sets the menu labels according to the currently set menu and the current command state.



SetRedoAccelerator(self, accel)

Sets the string that will be appended to the Redo menu item.

Parameters

accel (string) –



SetUndoAccelerator(self, accel)

Sets the string that will be appended to the Undo menu item.

Parameters

accel (string) –



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) –



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. Once Submit 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

See GetCurrentCommand



EditMenu

See GetEditMenu and SetEditMenu



MaxCommands

See GetMaxCommands



RedoAccelerator

See GetRedoAccelerator and SetRedoAccelerator



RedoMenuLabel

See GetRedoMenuLabel



UndoAccelerator

See GetUndoAccelerator and SetUndoAccelerator



UndoMenuLabel

See GetUndoMenuLabel