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

Inheritance diagram for class
GridUpdateLocker:
|
|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: Optional[Grid]=None) -> 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: Optional[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
:rtype: `None`
.. method:: Create(self, grid : 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
:rtype: `None`
.. method:: __enter__(self)
.. method:: __exit__(self, exc_type, exc_val, exc_tb)