.. wxPython Phoenix documentation

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

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

.. include:: headings.inc



.. _wx.grid.GridUpdateLocker:

==========================================================================================================================================
|phoenix_title|  **wx.grid.GridUpdateLocker**
==========================================================================================================================================

This small class can be used to prevent :ref:`wx.grid.Grid`  from redrawing during its lifetime by calling :meth:`wx.grid.Grid.BeginBatch`   in its constructor and :meth:`wx.grid.Grid.EndBatch`   in its destructor.          

It is typically used in a function performing several operations with a grid which would otherwise result in flicker. For example: 

::

    def GridLocker(self):

        self.grid = wx.grid.Grid(self, -1)

        noUpdates = wx.grid.GridUpdateLocker(self.grid)
        self.grid.AppendColumn()
        # ... many other operations with self.grid ...
        self.grid.AppendRow()

        # destructor called, grid refreshed



Using this class is easier and safer than calling :meth:`wx.grid.Grid.BeginBatch`   and :meth:`wx.grid.Grid.EndBatch`   because you don't risk missing the call the latter (due to an exception for example). 









|

|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>GridUpdateLocker</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.grid.GridUpdateLocker_inheritance.png" alt="Inheritance diagram of GridUpdateLocker" 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.grid.GridUpdateLocker.html" title="This small class can be used to prevent wx.grid.Grid  from redrawing during its lifetime by calling wx.grid.Grid.BeginBatch   in its constructor and wx.grid.Grid.EndBatch   in its destructor." alt="" coords="5,5,201,35"/> </map> 
   </p>
   </div>

|


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

================================================================================ ================================================================================
:meth:`~wx.grid.GridUpdateLocker.__init__`                                       Creates an object preventing the updates of the specified `grid`.
:meth:`~wx.grid.GridUpdateLocker.Create`                                         This method can be called if the object had been constructed using the default constructor.
:meth:`~wx.grid.GridUpdateLocker.__enter__`                                      
:meth:`~wx.grid.GridUpdateLocker.__exit__`                                       
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: wx.grid.GridUpdateLocker(object)

   **Possible constructors**::

       GridUpdateLocker(grid=None)
       
   
   This small class can be used to prevent Grid from redrawing during
   its lifetime by calling `Grid.BeginBatch()` in its constructor and
   `Grid.EndBatch()` in its destructor.



   .. method:: __init__(self, grid=None)

      Creates an object preventing the updates of the specified `grid`.                  

      The parameter could be ``None`` in which case nothing is done. If `grid`  is not ``None`` then the grid must exist for longer than this :ref:`wx.grid.GridUpdateLocker`  object itself. 

      The default constructor could be followed by a call to :meth:`Create`   to set the grid object later.                  


      :param `grid`: 
      :type `grid`: wx.grid.Grid







   .. method:: Create(self, grid)

      This method can be called if the object had been constructed using the default constructor.                  

      It must not be called more than once.                  


      :param `grid`: 
      :type `grid`: wx.grid.Grid







   .. method:: __enter__(self)




   .. method:: __exit__(self, exc_type, exc_val, exc_tb)