Inheritance diagram for wx.grid.Grid:
wx.grid.Grid and its related classes are used for displaying and editing tabular data. They provide a rich set of features for display, editing, and interacting with a variety of data sources.
For simple applications, and to help you get started, wx.grid.Grid is the only class you need to refer to directly. It will set up default instances of the other classes and manage them for you. For more complex applications you can derive your own classes for custom grid views, grid data tables, cell editors and renderers.
wx.grid.Grid has been greatly expanded and redesigned for wxPython 2.2 onwards.
A wx.grid.GridTableBase class holds the actual data to be displayed by a wx.grid.Grid class. One or more wx.grid.Grid classes may act as a view for one table class. The default table class is called wx.grid.GridStringTable and holds an array of strings. An instance of such a class is created by CreateGrid.
wx.grid.GridCellRenderer is the abstract base class for rendereing contents in a cell. The following renderers are predefined:
The look of a cell can be further defined using wx.grid.GridCellAttr. An object of this type may be returned by wx.grid.GridTableBase.GetAttr.
wx.grid.GridCellEditor is the abstract base class for editing the value of a cell. The following editors are predefined:
The event handler for the following functions takes a wx.grid.GridEvent parameter. The ..._CMD_... variants also take a window identifier.
Event Name | Description |
---|---|
wx.grid.EVT_GRID_CELL_LEFT_CLICK(func) | The user clicked a cell with the left mouse button. Processes a wx.grid.wxEVT_GRID_CELL_LEFT_CLICK. |
wx.grid.EVT_GRID_CELL_RIGHT_CLICK(func) | The user clicked a cell with the right mouse button. Processes a wx.grid.wxEVT_GRID_CELL_RIGHT_CLICK. |
wx.grid.EVT_GRID_CELL_LEFT_DCLICK(func) | The user double-clicked a cell with the left mouse button. Processes a wx.grid.wxEVT_GRID_CELL_LEFT_DCLICK. |
wx.grid.EVT_GRID_CELL_RIGHT_DCLICK(func) | The user double-clicked a cell with the right mouse button. Processes a wx.grid.wxEVT_GRID_CELL_RIGHT_DCLICK. |
wx.grid.EVT_GRID_LABEL_LEFT_CLICK(func) | The user clicked a label with the left mouse button. Processes a wx.grid.wxEVT_GRID_LABEL_LEFT_CLICK. |
wx.grid.EVT_GRID_LABEL_RIGHT_CLICK(func) | The user clicked a label with the right mouse button. Processes a wx.grid.wxEVT_GRID_LABEL_RIGHT_CLICK. |
wx.grid.EVT_GRID_LABEL_LEFT_DCLICK(func) | The user double-clicked a label with the left mouse button. Processes a wx.grid.wxEVT_GRID_LABEL_LEFT_DCLICK. |
wx.grid.EVT_GRID_LABEL_RIGHT_DCLICK(func) | The user double-clicked a label with the right mouse button. Processes a wx.grid.wxEVT_GRID_LABEL_RIGHT_DCLICK. |
wx.grid.EVT_GRID_CELL_CHANGE(func) | The user changed the data in a cell. Processes a wx.grid.wxEVT_GRID_CELL_CHANGE. |
wx.grid.EVT_GRID_SELECT_CELL(func) | The user moved to, and selected a cell. Processes a wx.grid.wxEVT_GRID_SELECT_CELL. |
wx.grid.EVT_GRID_EDITOR_HIDDEN(func) | The editor for a cell was hidden. Processes a wx.grid.wxEVT_GRID_EDITOR_HIDDEN. |
wx.grid.EVT_GRID_EDITOR_SHOWN(func) | The editor for a cell was shown. Processes a wx.grid.wxEVT_GRID_EDITOR_SHOWN. |
wx.grid.EVT_GRID_CMD_CELL_LEFT_CLICK(id, func) | The user clicked a cell with the left mouse button; variant taking a window identifier. Processes a wx.grid.wxEVT_GRID_CELL_LEFT_CLICK. |
wx.grid.EVT_GRID_CMD_CELL_RIGHT_CLICK(id, func) | The user clicked a cell with the right mouse button; variant taking a window identifier. Processes a wx.grid.wxEVT_GRID_CELL_RIGHT_CLICK. |
wx.grid.EVT_GRID_CMD_CELL_LEFT_DCLICK(id, func) | The user double-clicked a cell with the left mouse button; variant taking a window identifier. Processes a wx.grid.wxEVT_GRID_CELL_LEFT_DCLICK. |
wx.grid.EVT_GRID_CMD_CELL_RIGHT_DCLICK(id, func) | The user double-clicked a cell with the right mouse button; variant taking a window identifier. Processes a wx.grid.wxEVT_GRID_CELL_RIGHT_DCLICK. |
wx.grid.EVT_GRID_CMD_LABEL_LEFT_CLICK(id, func) | The user clicked a label with the left mouse button; variant taking a window identifier. Processes a wx.grid.wxEVT_GRID_LABEL_LEFT_CLICK. |
wx.grid.EVT_GRID_CMD_LABEL_RIGHT_CLICK(id, func) | The user clicked a label with the right mouse button; variant taking a window identifier. Processes a wx.grid.wxEVT_GRID_LABEL_RIGHT_CLICK. |
wx.grid.EVT_GRID_CMD_LABEL_LEFT_DCLICK(id, func) | The user double-clicked a label with the left mouse button; variant taking a window identifier. Processes a wx.grid.wxEVT_GRID_LABEL_LEFT_DCLICK. |
wx.grid.EVT_GRID_CMD_LABEL_RIGHT_DCLICK(id, func) | The user double-clicked a label with the right mouse button; variant taking a window identifier. Processes a wx.grid.wxEVT_GRID_LABEL_RIGHT_DCLICK. |
wx.grid.EVT_GRID_CMD_CELL_CHANGE(id, func) | The user changed the data in a cell; variant taking a window identifier. Processes a wx.grid.wxEVT_GRID_CELL_CHANGE. |
wx.grid.EVT_GRID_CMD_SELECT_CELL(id, func) | The user moved to, and selected a cell; variant taking a window identifier. Processes a wx.grid.wxEVT_GRID_SELECT_CELL. |
wx.grid.EVT_GRID_CMD_EDITOR_HIDDEN(id, func) | The editor for a cell was hidden; variant taking a window identifier. Processes a wx.grid.wxEVT_GRID_EDITOR_HIDDEN. |
wx.grid.EVT_GRID_CMD_EDITOR_SHOWN(id, func) | The editor for a cell was shown; variant taking a window identifier. Processes a wx.grid.wxEVT_GRID_EDITOR_SHOWN. |
The event handler for the following functions takes a wx.grid.GridSizeEvent parameter. The ..._CMD_... variants also take a window identifier.
Event Name | Description |
---|---|
wx.grid.EVT_GRID_COL_SIZE(func) | The user resized a column by dragging it. Processes a wx.grid.wxEVT_GRID_COL_SIZE. |
wx.grid.EVT_GRID_ROW_SIZE(func) | The user resized a row by dragging it. Processes a wx.grid.wxEVT_GRID_ROW_SIZE. |
wx.grid.EVT_GRID_CMD_COL_SIZE(func) | The user resized a column by dragging it; variant taking a window identifier. Processes a wx.grid.wxEVT_GRID_COL_SIZE. |
wx.grid.EVT_GRID_CMD_ROW_SIZE(func) | The user resized a row by dragging it; variant taking a window identifier. Processes a wx.grid.wxEVT_GRID_ROW_SIZE. |
The event handler for the following functions takes a wx.grid.GridRangeSelectEvent parameter. The ..._CMD_... variants also take a window identifier.
Event Name | Description |
---|---|
wx.grid.EVT_GRID_RANGE_SELECT(func) | The user selected a group of contiguous cells. Processes a wx.grid.wxEVT_GRID_RANGE_SELECT. |
wx.grid.EVT_GRID_CMD_RANGE_SELECT(id, func) | The user selected a group of contiguous cells; variant taking a window identifier. Processes a wx.grid.wxEVT_GRID_RANGE_SELECT. |
The event handler for the following functions takes a wx.grid.GridEditorCreatedEvent parameter. The ..._CMD_... variants also take a window identifier.
Event Name | Description |
---|---|
wx.grid.EVT_GRID_EDITOR_CREATED(func) | The editor for a cell was created. Processes a wx.grid.wxEVT_GRID_EDITOR_CREATED. |
wx.grid.EVT_GRID_CMD_EDITOR_CREATED(id, func) | The editor for a cell was created; variant taking a window identifier. Processes a wx.grid.wxEVT_GRID_EDITOR_CREATED. |
Constructor to create a grid object.
Call either CreateGrid or SetTable directly after this to initialize the grid before using it.
Parameters:
Returns:
Appends one or more new columns to the right of the grid and returns True if successful. The updateLabels argument is not used at present.
If you are using a derived grid table class you will need to override wx.grid.GridTableBase.AppendCols.
See InsertCols for further information.
Parameters:
Returns:
bool
Appends one or more new rows to the right of the grid and returns True if successful. The updateLabels argument is not used at present.
If you are using a derived grid table class you will need to override wx.grid.GridTableBase.AppendRows.
See InsertRows for further information.
Parameters:
Returns:
bool
Note
wx.grid.Grid sets up arrays to store individual row and column sizes when non-default sizes are used. The memory requirements for this could become prohibitive if your grid is very large.
Parameters:
Automatically sizes the column col to fit its contents.
If setAsMin is True the calculated width will also be set as the minimal width for the column.
Parameters:
Note
wx.grid.Grid sets up arrays to store individual row and column sizes when non-default sizes are used. The memory requirements for this could become prohibitive if your grid is very large.
Automatically sizes all columns to fit their contents.
If setAsMin is True the calculated widths will also be set as the minimal widths for the columns.
Parameters:
Note
wx.grid.Grid sets up arrays to store individual row and column sizes when non-default sizes are used. The memory requirements for this could become prohibitive if your grid is very large.
Automatically sizes the row row to fit its contents.
If setAsMin is True the calculated height will also be set as the minimal height for the row.
Parameters:
Note
wx.grid.Grid sets up arrays to store individual row and column sizes when non-default sizes are used. The memory requirements for this could become prohibitive if your grid is very large.
Parameters:
Automatically sizes all rows to fit their contents.
If setAsMin is True the calculated heights will also be set as the minimal heights for the rows.
Parameters:
Note
wx.grid.Grid sets up arrays to store individual row and column sizes when non-default sizes are used. The memory requirements for this could become prohibitive if your grid is very large.
Increments the grid’s batch count. When the count is greater than zero repainting of the grid is suppressed. Each call to BeginBatch must be matched by a later call to EndBatch.
Code that does a lot of grid modification can be enclosed between BeginBatch and EndBatch calls to avoid screen flicker. The final EndBatch will cause the grid to be repainted.
This function returns the rectangle that encloses the block of cells limited by topLeft and bottomRight cell in device coords and clipped to the client size of the grid window.
Parameters:
Returns:
Returns True if columns can be moved by dragging with the mouse. Columns can be moved by dragging on their labels.
Returns:
bool
Returns True if columns can be resized by dragging with the mouse. Columns can be resized by dragging the edges of their labels.
If grid line dragging is enabled they can also be resized by dragging the right edge of the column in the grid cell area
Returns:
bool
See also
Return True if the dragging of grid lines to resize rows and columns is enabled or False otherwise.
Returns:
bool
Returns True if rows can be resized by dragging with the mouse. Rows can be resized by dragging the edges of their labels.
If grid line dragging is enabled they can also be resized by dragging the lower edge of the row in the grid cell area
Returns:
bool
See also
Returns True if the in-place edit control for the current grid cell can be used and False otherwise (e.g. if the current cell is read-only).
Returns:
bool
Return the rectangle corresponding to the grid cell’s size and position in logical coordinates.
Parameters:
Returns:
Clears all data in the underlying grid table and repaints the grid. The table is not deleted by this function.
If you are using a derived table class then you need to override wx.grid.GridTableBase.Clear for this function to have any effect.
Creates a grid with the specified initial number of rows and columns. Call this directly after the grid constructor.
When you use this function wx.Grid will create and manage a simple table of string values for you. All of the grid data will be stored in memory.
For applications with more complex data types or relationships, or for dealing with very large datasets, you should derive your own grid table class and pass a table object to the grid with SetTable.
Parameters:
Returns:
bool
See also
Deletes one or more columns from a grid starting at the specified position and returns True if successful. The updateLabels argument is not used at present.
If you are using a derived grid table class you will need to override wx.grid.GridTableBase.DeleteCols.
See InsertCols for further information.
Parameters:
Returns:
bool
Deletes one or more rows from a grid starting at the specified position and returns True if successful. The updateLabels argument is not used at present.
If you are using a derived grid table class you will need to override wx.grid.GridTableBase.DeleteRows.
See InsertRows for further information.
Parameters:
Returns:
bool
Parameters:
Parameters:
Parameters:
Disables in-place editing of grid cells.
Equivalent to calling EnableCellEditControl (False).
Disables column moving by dragging with the mouse.
Equivalent to passing False to EnableDragColMove.
Disables column sizing by dragging with the mouse.
Equivalent to passing False to EnableDragColSize.
Disable mouse dragging of grid lines to resize rows and columns.
Equivalent to passing False to EnableDragGridSize
Disables row sizing by dragging with the mouse.
Equivalent to passing False to EnableDragRowSize.
Parameters:
Parameters:
Enables or disables in-place editing of grid cell data.
The grid will issue either a wx.grid.EVT_GRID_EDITOR_SHOWN or wx.grid.EVT_GRID_EDITOR_HIDDEN event.
Parameters:
Parameters:
Enables or disables column moving by dragging with the mouse.
Parameters:
Enables or disables column sizing by dragging with the mouse.
Parameters:
Enables or disables row and column resizing by dragging gridlines with the mouse.
Parameters:
Enables or disables row sizing by dragging with the mouse.
Parameters:
If the edit argument is False this function sets the whole grid as read-only. If the argument is True the grid is set to the default state where cells may be editable. In the default state you can set single grid cells and whole rows and columns to be editable or read-only via wx.grid.GridCellAtt.SetReadOnly.
For single cells you can also use the shortcut function SetReadOnly.
For more information about controlling grid cell attributes see the wx.grid.GridCellAttr cell attribute class.
Parameters:
Turns the drawing of grid lines on or off.
Parameters:
Decrements the grid’s batch count. When the count is greater than zero repainting of the grid is suppressed. Each previous call to BeginBatch must be matched by a later call to EndBatch.
Code that does a lot of grid modification can be enclosed between BeginBatch and EndBatch calls to avoid screen flicker. The final EndBatch will cause the grid to be repainted.
Overrides wx.Window.Fit
Reimplemented from wx.Window
Returns the number of times that BeginBatch has been called without (yet) matching calls to EndBatch.
While the grid’s batch count is greater than zero the display will not be updated.
Returns:
int
Sets the arguments to the horizontal and vertical text alignment values for the grid cell at the specified location.
Horizontal alignment will be one of wx.ALIGN_LEFT, wx.ALIGN_CENTRE or wx.ALIGN_RIGHT. Vertical alignment will be one of wx.ALIGN_TOP, wx.ALIGN_CENTRE or wx.ALIGN_BOTTOM.
Parameters:
Returns:
(horiz, vert)
Returns the background colour of the cell at the specified location.
Parameters:
Returns:
Returns a pointer to the editor for the cell at the specified location.
See wx.grid.GridCellEditor for more information about cell editors and renderers.
Parameters:
Returns:
Returns the font for text in the grid cell at the specified location.
Parameters:
Returns:
Parameters:
Returns:
bool
Returns a pointer to the renderer for the grid cell at the specified location.
See wx.grid.GridCellRenderer for more information about cell editors and renderers.
Parameters:
Returns:
Parameters:
Returns:
(num_rows, num_cols)
Returns the text colour for the grid cell at the specified location.
Parameters:
Returns:
Returns the string contained in the cell at the specified location.
For simple applications where a grid object automatically uses a default grid table of string values you use this function together with SetCellValue to access cell values.
For more complex applications where you have derived your own grid table class that contains various data types (e.g. numeric, boolean or user-defined custom types) then you only use this function for those cells that contain string values.
See wx.grid.GridTableBase.CanGetValueAs for more information.
Parameters:
Returns:
string
Returns the column ID of the specified column position.
Parameters:
Returns:
int
Returns the pen used for vertical grid lines.
This virtual function may be overridden in derived classes in order to change the appearance of individual grid lines for the given column col.
See GetRowGridLinePen for an example.
Parameters:
Returns:
Sets the arguments to the current column label alignment values.
Horizontal alignment will be one of wx.ALIGN_LEFT, wx.ALIGN_CENTRE or wx.ALIGN_RIGHT. Vertical alignment will be one of wx.ALIGN_TOP, wx.ALIGN_CENTRE or wx.ALIGN_BOTTOM.
Returns:
(horiz, vert)
Returns the current height of the column labels.
Returns:
int
Returns the specified column label. The default grid table class provides column labels of the form A, B, ..., Z, AA, AB, ..., ZZ, AAA...
If you are using a custom grid table you can override wx.grid.GridTableBase.GetColLabelValue to provide your own labels.
Parameters:
Returns:
string
This returns the value of the lowest column width that can be handled correctly.
Returns:
int
See also
Returns the position of the specified column.
Parameters:
Returns:
int
Returns the width of the specified column.
Parameters:
Returns:
int
Sets the arguments to the current default horizontal and vertical text alignment values.
Horizontal alignment will be one of wx.ALIGN_LEFT, wx.ALIGN_CENTRE or wx.ALIGN_RIGHT. Vertical alignment will be one of wx.ALIGN_TOP, wx.ALIGN_CENTRE or wx.ALIGN_BOTTOM.
Returns:
(horiz, vert)
Returns the current default background colour for grid cells.
Returns:
Returns the current default colour for grid cell text.
Returns:
Returns the default height for column labels.
Returns:
int
Returns the current default width for grid columns.
Returns:
int
Returns a pointer to the current default grid cell editor.
See wx.grid.GridCellEditor for more information about cell editors and renderers.
Returns:
Parameters:
Returns:
Parameters:
Returns:
Returns the pen used for grid lines.
This virtual function may be overridden in derived classes in order to change the appearance of grid lines.
Returns:
Note
Note that currently the pen width must be 1.
See also
Returns a pointer to the current default grid cell renderer.
See wx.grid.GridCellEditor for more information about cell editors and renderers.
Returns:
Parameters:
Returns:
Parameters:
Returns:
Returns the default width for the row labels.
Returns:
int
Returns the current default height for grid rows.
Returns:
int
Returns the current grid cell column position.
Returns:
int
Returns the current grid cell row position.
Returns:
int
See also
Returns the colour used for the background of row and column labels.
Returns:
Returns the total number of grid columns (actually the number of columns in the underlying grid table).
Returns:
int
Returns the total number of grid rows (actually the number of rows in the underlying grid table).
Returns:
int
Parameters:
Returns:
Returns the pen used for horizontal grid lines.
This virtual function may be overridden in derived classes in order to change the appearance of individual grid line for the given row row.
Example:
# In a grid displaying music notation, use a solid black pen between
# octaves (C0=row 127, C1=row 115 etc.)
def GetRowGridLinePen(row):
if row%12 == 7:
return wx.Pen(wx.BLACK, 1, wx.SOLID)
else:
return self.GetDefaultGridLinePen()
Parameters:
Returns:
Sets the arguments to the current row label alignment values.
Horizontal alignment will be one of wx.ALIGN_LEFT, wx.ALIGN_CENTRE or wx.ALIGN_RIGHT. Vertical alignment will be one of wx.ALIGN_TOP, wx.ALIGN_CENTRE or wx.ALIGN_BOTTOM.
Returns:
(horiz, vert)
Returns the current width of the row labels.
Returns:
int
Returns the specified row label. The default grid table class provides numeric row labels.
If you are using a custom grid table you can override wx.grid.GridTableBase.GetRowLabelValue to provide your own labels.
Parameters:
Returns:
string
This returns the value of the lowest row width that can be handled correctly.
Returns:
int
See also
Returns the height of the specified row.
Parameters:
Returns:
int
Returns the number of pixels per horizontal scroll increment.
The default is 15.
Returns:
int
See also
Returns the number of pixels per vertical scroll increment.
The default is 15.
Returns:
int
See also
Parameters:
Returns:
int
Parameters:
Returns:
int
Returns an array of singly selected cells.
Returns:
list of wx.grid.GridCellCoords
Returns an array of selected columns.
Returns:
list of integers
Returns an array of selected rows.
Returns:
list of integers
Returns an array of the bottom right corners of blocks of selected cells.
Returns:
list of wx.grid.GridCellCoords
See also
Returns an array of the top left corners of blocks of selected cells.
Returns:
list of wx.grid.GridCellCoords
See also
Returns the current selection mode.
Returns:
int
See also
Returns a base pointer to the current table object.
Returns:
Returns True if drawing of grid lines is turned on, False otherwise.
Returns:
bool
Inserts one or more new columns into a grid with the first new column at the specified position and returns True if successful. The updateLabels argument is not used at present.
The sequence of actions begins with the grid object requesting the underlying grid table to insert new columns. If this is successful the table notifies the grid and the grid updates the display. For a default grid (one where you have called CreateGrid) this process is automatic. If you are using a custom grid table (specified with SetTable) then you must override wx.grid.GridTableBase.InsertCols in your derived table class.
Parameters:
Returns:
bool
Inserts one or more new rows into a grid with the first new row at the specified position and returns True if successful. The updateLabels argument is not used at present.
The sequence of actions begins with the grid object requesting the underlying grid table to insert new rows. If this is successful the table notifies the grid and the grid updates the display. For a default grid (one where you have called CreateGrid) this process is automatic. If you are using a custom grid table (specified with SetTable) then you must override wx.grid.GridTableBase.InsertRows in your derived table class.
Parameters:
Returns:
bool
Returns True if the in-place edit control is currently enabled.
Returns:
bool
Returns True if the current cell has been set to read-only.
Returns:
bool
See also
Returns False if the whole grid has been set as read-only or True otherwise.
See EnableEditing for more information about controlling the editing status of grid cells.
Returns:
bool
Is this cell currently selected?
Parameters:
Returns:
bool
Returns True if the cell at the specified location can’t be edited.
Parameters:
Returns:
bool
See also
Returns True if there are currently rows, columns or blocks of cells selected.
Returns:
bool
Returns True if a cell is either wholly visible (the default) or at least partially visible in the grid window.
Parameters:
Returns:
bool
Brings the specified cell into the visible grid cell area with minimal scrolling.
Does nothing if the cell is already visible.
Parameters:
Moves the grid cursor down by one row. If a block of cells was previously selected it will expand if the argument is True or be cleared if the argument is False.
Parameters:
Returns:
bool
Note
Keyboard note: This function is called for Down cursor key presses or Shift+Down to expand a selection.
Moves the grid cursor down in the current column such that it skips to the beginning or end of a block of non-empty cells. If a block of cells was previously selected it will expand if the argument is True or be cleared if the argument is False.
Parameters:
Returns:
bool
Note
Keyboard note: This function is called for Ctrl+Down cursor key presses or Shift+Ctrl+Down to expand a selection.
Moves the grid cursor left by one column. If a block of cells was previously selected it will expand if the argument is True or be cleared if the argument is False.
Parameters:
Returns:
bool
Note
Keyboard note: This function is called for Left cursor key presses or Shift+Left to expand a selection.
Moves the grid cursor left in the current row such that it skips to the beginning or end of a block of non-empty cells. If a block of cells was previously selected it will expand if the argument is True or be cleared if the argument is False.
Parameters:
Returns:
bool
Note
Keyboard note: This function is called for Ctrl+Left cursor key presses or Shift+Ctrl+Left to expand a selection.
Moves the grid cursor right by one column. If a block of cells was previously selected it will expand if the argument is True or be cleared if the argument is False.
Parameters:
Returns:
bool
Note
Keyboard note: This function is called for Right cursor key presses or Shift+Right to expand a selection.
Moves the grid cursor right in the current row such that it skips to the beginning or end of a block of non-empty cells. If a block of cells was previously selected it will expand if the argument is True or be cleared if the argument is False.
Parameters:
Returns:
bool
Note
Keyboard note: This function is called for Ctrl+Right cursor key presses or Shift+Ctrl+Right to expand a selection.
Moves the grid cursor up by one row. If a block of cells was previously selected it will expand if the argument is True or be cleared if the argument is False.
Parameters:
Returns:
bool
Note
Keyboard note: This function is called for Up cursor key presses or Shift+Up to expand a selection.
Moves the grid cursor up in the current column such that it skips to the beginning or end of a block of non-empty cells. If a block of cells was previously selected it will expand if the argument is True or be cleared if the argument is False.
Parameters:
Returns:
bool
Note
Keyboard note: This function is called for Ctrl+Up cursor key presses or Shift+Ctrl+Up to expand a selection.
Moves the grid cursor down by some number of rows so that the previous bottom visible row becomes the top visible row.
Returns:
bool
Note
Keyboard note: This function is called for PgDn key presses.
Moves the grid cursor up by some number of rows so that the previous top visible row becomes the bottom visible row.
Returns:
bool
Note
Keyboard note: This function is called for PgUp key presses.
Methods for a registry for mapping data types to Renderers/Editors.
Parameters:
Sets the value of the current grid cell to the current in-place edit control value.
This is called automatically when the grid cursor moves from the current cell to a new cell. It is also a good idea to call this function when closing a grid since any edits to the final cell location will not be saved otherwise.
Selects a rectangular block of cells.
If addToSelected is False then any existing selection will be deselected; if True the column will be added to the existing selection.
Parameters:
Selects the specified column.
If addToSelected is False then any existing selection will be deselected; if True the column will be added to the existing selection.
Parameters:
Selects the specified row.
If addToSelected is False then any existing selection will be deselected; if True the row will be added to the existing selection.
Parameters:
Parameters:
Sets the horizontal and vertical alignment for grid cell text at the specified location.
Horizontal alignment (horiz) should be one of wx.ALIGN_LEFT, wx.ALIGN_CENTRE or wx.ALIGN_RIGHT. Vertical alignment (vert) should be one of wx.ALIGN_TOP, wx.ALIGN_CENTRE or wx.ALIGN_BOTTOM.
Parameters:
Sets the cell background colour.
Parameters:
Sets the editor for the grid cell at the specified location. The grid will take ownership of the pointer.
See wx.grid.GridCellEditor for more information about cell editors and renderers.
Parameters:
Sets the font for text in the grid cell at the specified location.
Parameters:
Parameters:
Parameters:
Parameters:
Sets the renderer for the grid cell at the specified location. The grid will take ownership of the pointer.
See wx.grid.GridCellRenderer for more information about cell editors and renderers.
Parameters:
Parameters:
Sets the text colour for the grid cell at the specified location.
Parameters:
Sets the string value for the cell at the specified location.
For simple applications where a grid object automatically uses a default grid table of string values you use this function together with GetCellValue to access cell values.
For more complex applications where you have derived your own grid table class that contains various data types (e.g. numeric, boolean or user-defined custom types) then you only use this function for those cells that contain string values.
See wx.grid.GridTableBase.CanSetValueAs for more information.
Parameters:
Sets the cell attributes for all cells in the specified column.
For more information about controlling grid cell attributes see the wx.grid.GridCellAttr cell attribute class.
Parameters:
Sets the specified column to display boolean values.
wx.grid.Grid displays boolean values with a checkbox.
Parameters:
Sets the specified column to display data in a custom format.
Parameters:
Sets the specified column to display floating point values with the given width and precision.
Parameters:
Sets the specified column to display integer values.
Parameters:
Sets the horizontal and vertical alignment of column label text.
Horizontal alignment (horiz) should be one of wx.ALIGN_LEFT, wx.ALIGN_CENTRE or wx.ALIGN_RIGHT. Vertical alignment (vert) should be one of wx.ALIGN_TOP, wx.ALIGN_CENTRE or wx.ALIGN_BOTTOM.
Parameters:
Sets the height of the column labels.
If height equals to wx.grid.GRID_AUTOSIZE then the height is calculated automatically so that no label is truncated.
This flag is new since wxPython version 2.8.8.
Parameters:
Note
Note that this could be slow for a large table.
Parameters:
Set the value for the given column label.
If you are using a derived grid table you must override wx.grid.GridTableBase.SetColLabelValue for this to have any effect.
Parameters:
This modifies the minimum column width that can be handled correctly.
Specifying a low value here allows smaller grid cells to be dealt with correctly. Specifying a value here which is much smaller than the actual minimum size will incur a performance penalty in the functions which perform grid cell index lookup on the basis of screen coordinates.
This should normally be called when creating the grid because it will not resize existing columns with sizes smaller than the value specified here.
Parameters:
Sets the minimal width for the specified column.
This should normally be called when creating the grid because it will not resize a column that is already narrower than the minimal width. The width argument must be higher than the minimimal acceptable column width.
Parameters:
See also
Sets the position of the specified column.
Parameters:
Sets the width of the specified column.
This function does not refresh the grid. If you are calling it outside of a BeginBatch / EndBatch block you can use ForceRefresh to see the changes.
Parameters:
Note
wx.grid.Grid sets up arrays to store individual row and column sizes when non-default sizes are used. The memory requirements for this could become prohibitive if your grid is very large.
Sets the default horizontal and vertical alignment for grid cell text.
Horizontal alignment (horiz) should be one of wx.ALIGN_LEFT, wx.ALIGN_CENTRE or wx.ALIGN_RIGHT. Vertical alignment (vert) should be one of wx.ALIGN_TOP, wx.ALIGN_CENTRE or wx.ALIGN_BOTTOM.
Parameters:
Sets the default background colour for grid cells.
Parameters:
Sets the default font to be used for grid cell text.
Parameters:
Parameters:
Sets the current default colour for grid cell text.
Parameters:
Sets the default width for columns in the grid.
This will only affect columns subsequently added to the grid unless resizeExistingCols is True.
Parameters:
Sets the default editor for grid cells. The grid will take ownership of the pointer.
See wx.grid.GridCellEditor for more information about cell editors and renderers.
Parameters:
Sets the default renderer for grid cells. The grid will take ownership of the pointer.
See wx.grid.GridCellRenderer for more information about cell editors and renderers.
Parameters:
Sets the default height for rows in the grid.
This will only affect rows subsequently added to the grid unless resizeExistingRows is True.
Parameters:
Set the grid cursor to the specified cell. This function calls MakeCellVisible.
Parameters:
Sets the background colour for row and column labels.
Parameters:
Sets the colour for row and column label text.
Parameters:
A grid may occupy more space than needed for its rows/columns. This function allows to set how big this extra space is.
Parameters:
Makes the cell at the specified location read-only or editable.
Parameters:
See also
Sets the cell attributes for all cells in the specified row.
See the wx.grid.GridCellAttr class for more information about controlling cell attributes.
Parameters:
Sets the horizontal and vertical alignment of row label text.
Horizontal alignment (horiz) should be one of wx.ALIGN_LEFT, wx.ALIGN_CENTRE or wx.ALIGN_RIGHT. Vertical alignment (vert) should be one of wx.ALIGN_TOP, wx.ALIGN_CENTRE or wx.ALIGN_BOTTOM.
Parameters:
Sets the width of the row labels.
If width equals wx.grid.GRID_AUTOSIZE then the width is calculated automatically so that no label is truncated.
This flag is new since wxPython version 2.8.8.
Parameters:
Note
Note that this could be slow for a large table.
Set the value for the given row label.
If you are using a derived grid table you must override wx.grid.GridTableBase.SetRowLabelValue for this to have any effect.
Parameters:
This modifies the minimum row width that can be handled correctly.
Specifying a low value here allows smaller grid cells to be dealt with correctly. Specifying a value here which is much smaller than the actual minimum size will incur a performance penalty in the functions which perform grid cell index lookup on the basis of screen coordinates.
This should normally be called when creating the grid because it will not resize existing rows with sizes smaller than the value specified here.
Parameters:
Sets the minimal height for the specified row.
This should normally be called when creating the grid because it will not resize a row that is already shorter than the minimal height. The height argument must be higher than the minimimal acceptable row height.
Parameters:
See also
Sets the height of the specified row.
This function does not refresh the grid. If you are calling it outside of a BeginBatch / EndBatch block you can use ForceRefresh to see the changes.
Parameters:
Note
wx.grid.Grid sets up arrays to store individual row and column sizes when non-default sizes are used. The memory requirements for this could become prohibitive if your grid is very large.
Sets the number of pixels per horizontal scroll increment. The default is 15.
Sometimes wx.grid.Grid has trouble setting the scrollbars correctly due to rounding errors: setting this to 1 can help.
Parameters:
See also
Sets the number of pixels per vertical scroll increment. The default is 15.
Sometimes wx.grid.Grid has trouble setting the scrollbars correctly due to rounding errors: setting this to 1 can help.
Parameters:
See also
Set the selection behaviour of the grid.
selmode may be one of the following values (all members of wx.grid.Grid class):
Selection Mode | Description |
---|---|
wxGridSelectCells | The default mode when individual cells are selected. |
wxGridSelectRows | Selections will consist of whole rows. |
wxGridSelectCols | Selections will consist of whole columns. |
Parameters:
Passes a pointer to a custom grid table to be used by the grid.
This should be called after the grid constructor and before using the grid object. If takeOwnership is set to True then the table will be deleted by the wx.grid.Grid destructor.
Use this function instead of CreateGrid when your application involves complex or non-string data or data sets that are too large to fit wholly in memory.
Parameters:
Returns:
bool
See also
Returns the grid column that corresponds to the logical x coordinate. Returns wx.NOT_FOUND if there is no column at the x position.
Parameters:
Returns:
int
Returns the column whose right hand edge is close to the given logical x position.
If no column edge is near to this position wx.NOT_FOUND is returned.
Parameters:
Returns:
int
Parameters:
Returns:
wx.grid.GridCellCoords
Returns the row whose bottom edge is close to the given logical y position.
If no row edge is near to this position wx.NOT_FOUND is returned.
Parameters:
Returns:
int
Returns the grid row that corresponds to the logical y coordinate. Returns wx.NOT_FOUND if there is no row at the y position.
Parameters:
Returns:
int