.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2020 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc



.. _wx.CommandProcessor:

==========================================================================================================================================
|phoenix_title|  **wx.CommandProcessor**
==========================================================================================================================================

:ref:`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. 








         



.. seealso:: :ref:`CommandProcessor Overview <commandprocessor overview>`, :ref:`wx.Command`    







|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>CommandProcessor</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.CommandProcessor_inheritance.svg" alt="Inheritance diagram of CommandProcessor" usemap="#dummy" class="inheritance"/></center>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.CommandProcessor.html" title="wx.CommandProcessor  is a class that maintains a history of Commands, with undo/redo functionality built-in." alt="" coords="5,82,204,111"/> <area shape="rect" id="node2" href="wx.Object.html" title="This is the root class of many of the wxWidgets classes." alt="" coords="55,5,154,34"/> </map> 
   </p>
   </div>

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.CommandProcessor.__init__`                                            Constructor.
:meth:`~wx.CommandProcessor.CanRedo`                                             Returns ``True`` if the currently-active command can be redone, ``False`` otherwise.
:meth:`~wx.CommandProcessor.CanUndo`                                             Returns ``True`` if the currently-active command can be undone, ``False`` otherwise.
:meth:`~wx.CommandProcessor.ClearCommands`                                       Deletes all commands in the list and sets the current command pointer to nullptr.
:meth:`~wx.CommandProcessor.GetCommands`                                         Returns the list of commands.
:meth:`~wx.CommandProcessor.GetCurrentCommand`                                   Returns the current command.
:meth:`~wx.CommandProcessor.GetEditMenu`                                         Returns the edit menu associated with the command processor.
:meth:`~wx.CommandProcessor.GetMaxCommands`                                      Returns the maximum number of commands that the command processor stores.
:meth:`~wx.CommandProcessor.GetRedoAccelerator`                                  Returns the string that will be appended to the Redo menu item.
:meth:`~wx.CommandProcessor.GetRedoMenuLabel`                                    Returns the string that will be shown for the redo menu item.
:meth:`~wx.CommandProcessor.GetUndoAccelerator`                                  Returns the string that will be appended to the Undo menu item.
:meth:`~wx.CommandProcessor.GetUndoMenuLabel`                                    Returns the string that will be shown for the undo menu item.
:meth:`~wx.CommandProcessor.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).
:meth:`~wx.CommandProcessor.IsDirty`                                             Returns a boolean value that indicates if changes have been made since the last save operation.
:meth:`~wx.CommandProcessor.MarkAsSaved`                                         You must call this method whenever the project is saved if you plan to use :meth:`~CommandProcessor.IsDirty` .
:meth:`~wx.CommandProcessor.Redo`                                                Executes (redoes) the current command (the command that has just been undone if any).
:meth:`~wx.CommandProcessor.SetEditMenu`                                         Tells the command processor to update the Undo and Redo items on this menu as appropriate.
:meth:`~wx.CommandProcessor.SetMenuStrings`                                      Sets the menu labels according to the currently set menu and the current command state.
:meth:`~wx.CommandProcessor.SetRedoAccelerator`                                  Sets the string that will be appended to the Redo menu item.
:meth:`~wx.CommandProcessor.SetUndoAccelerator`                                  Sets the string that will be appended to the Undo menu item.
:meth:`~wx.CommandProcessor.Store`                                               Just store the command without executing it.
:meth:`~wx.CommandProcessor.Submit`                                              Submits a new command to the command processor.
:meth:`~wx.CommandProcessor.Undo`                                                Undoes the last command executed.
================================================================================ ================================================================================


|


|property_summary| Properties Summary
=====================================

================================================================================ ================================================================================
:attr:`~wx.CommandProcessor.Commands`                                            See :meth:`~wx.CommandProcessor.GetCommands`
:attr:`~wx.CommandProcessor.CurrentCommand`                                      See :meth:`~wx.CommandProcessor.GetCurrentCommand`
:attr:`~wx.CommandProcessor.EditMenu`                                            See :meth:`~wx.CommandProcessor.GetEditMenu` and :meth:`~wx.CommandProcessor.SetEditMenu`
:attr:`~wx.CommandProcessor.MaxCommands`                                         See :meth:`~wx.CommandProcessor.GetMaxCommands`
:attr:`~wx.CommandProcessor.RedoAccelerator`                                     See :meth:`~wx.CommandProcessor.GetRedoAccelerator` and :meth:`~wx.CommandProcessor.SetRedoAccelerator`
:attr:`~wx.CommandProcessor.RedoMenuLabel`                                       See :meth:`~wx.CommandProcessor.GetRedoMenuLabel`
:attr:`~wx.CommandProcessor.UndoAccelerator`                                     See :meth:`~wx.CommandProcessor.GetUndoAccelerator` and :meth:`~wx.CommandProcessor.SetUndoAccelerator`
:attr:`~wx.CommandProcessor.UndoMenuLabel`                                       See :meth:`~wx.CommandProcessor.GetUndoMenuLabel`
================================================================================ ================================================================================


|


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



   .. method:: __init__(self, maxCommands=-1)

      Constructor. 
                 




      :param `maxCommands`: 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.   
      :type `maxCommands`: int






      :rtype: `None`     




                  





   .. method:: CanRedo(self)

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

      :rtype: `bool`








   .. method:: CanUndo(self)

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

      :rtype: `bool`








   .. method:: ClearCommands(self)

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

      :rtype: `None`     








   .. method:: GetCommands(self)

      Returns the list of commands. 
                 

      :rtype: `CommandList`     








   .. method:: GetCurrentCommand(self)

      Returns the current command. 
                 

      :rtype: :ref:`wx.Command`








   .. method:: GetEditMenu(self)

      Returns the edit menu associated with the command processor. 
                 

      :rtype: :ref:`wx.Menu`








   .. method:: GetMaxCommands(self)

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

      :rtype: `int`








   .. method:: GetRedoAccelerator(self)

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

      :rtype: `str`








   .. method:: GetRedoMenuLabel(self)

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

      :rtype: `str`








   .. method:: GetUndoAccelerator(self)

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

      :rtype: `str`








   .. method:: GetUndoMenuLabel(self)

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

      :rtype: `str`








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

      :rtype: `None`     








   .. method:: IsDirty(self)

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

      This only works if :meth:`MarkAsSaved`   is called whenever the project is saved. 
                 

      :rtype: `bool`








   .. method:: MarkAsSaved(self)

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

      :rtype: `None`     








   .. method:: Redo(self)

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

      :rtype: `bool`








   .. method:: SetEditMenu(self, menu)

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

      Set this to nullptr 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. 
                 


      :param `menu`: 
      :type `menu`: wx.Menu




      :rtype: `None`     








   .. method:: SetMenuStrings(self)

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

      :rtype: `None`     








   .. method:: SetRedoAccelerator(self, accel)

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


      :param `accel`: 
      :type `accel`: string




      :rtype: `None`     








   .. method:: SetUndoAccelerator(self, accel)

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


      :param `accel`: 
      :type `accel`: string




      :rtype: `None`     








   .. method:: 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. 
                 


      :param `command`: 
      :type `command`: wx.Command




      :rtype: `None`     








   .. method:: Submit(self, command, storeIt=True)

      Submits a new command to the command processor. 
                 

      The command processor calls :meth:`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 :meth:`Submit`   has been called, the passed command should not be deleted directly by the application. 




      :param `command`: The command to submit   
      :type `command`: wx.Command
      :param `storeIt`: Indicates whether the successful command should be stored in the history list.   
      :type `storeIt`: bool








      :rtype: `bool`




                  





   .. method:: Undo(self)

      Undoes the last command executed. 
                 

      :rtype: `bool`








   .. attribute:: Commands

      See :meth:`~wx.CommandProcessor.GetCommands`


   .. attribute:: CurrentCommand

      See :meth:`~wx.CommandProcessor.GetCurrentCommand`


   .. attribute:: EditMenu

      See :meth:`~wx.CommandProcessor.GetEditMenu` and :meth:`~wx.CommandProcessor.SetEditMenu`


   .. attribute:: MaxCommands

      See :meth:`~wx.CommandProcessor.GetMaxCommands`


   .. attribute:: RedoAccelerator

      See :meth:`~wx.CommandProcessor.GetRedoAccelerator` and :meth:`~wx.CommandProcessor.SetRedoAccelerator`


   .. attribute:: RedoMenuLabel

      See :meth:`~wx.CommandProcessor.GetRedoMenuLabel`


   .. attribute:: UndoAccelerator

      See :meth:`~wx.CommandProcessor.GetUndoAccelerator` and :meth:`~wx.CommandProcessor.SetUndoAccelerator`


   .. attribute:: UndoMenuLabel

      See :meth:`~wx.CommandProcessor.GetUndoMenuLabel`

