Phoenix Logo

phoenix_title wx.grid.GridUpdateLocker

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.

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 wx.grid.Grid.BeginBatch and wx.grid.Grid.EndBatch because you don’t risk missing the call the latter (due to an exception for example).


class_hierarchy Class Hierarchy

Inheritance diagram for class GridUpdateLocker:


method_summary Methods Summary

__init__ Creates an object preventing the updates of the specified grid.
Create This method can be called if the object had been constructed using the default constructor.
__enter__  
__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.


Methods



__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 wx.grid.GridUpdateLocker object itself.

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

Parameters:grid (wx.grid.Grid) –


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.

Parameters:grid (wx.grid.Grid) –


__enter__(self)


__exit__(self, exc_type, exc_val, exc_tb)