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. The Grid Overview has examples of simple and more complex applications, explains the relationship between the various grid classes and has a summary of the keyboard shortcuts and mouse functions provided by wx.grid.Grid.
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 rendering 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:
Please see wx.grid.GridEvent, wx.grid.GridSizeEvent, wx.grid.GridRangeSelectEvent, and wx.grid.GridEditorCreatedEvent for the documentation of all event types you can use with wx.grid.Grid.
See also
__init__ |
Default constructor. |
AppendCols |
Appends one or more new columns to the right of the grid. |
AppendRows |
Appends one or more new rows to the bottom of the grid. |
AreHorzGridLinesClipped |
Return True if the horizontal grid lines stop at the last column boundary or False if they continue to the end of the window. |
AreVertGridLinesClipped |
Return True if the vertical grid lines stop at the last row boundary or False if they continue to the end of the window. |
AutoSize |
Automatically sets the height and width of all rows and columns to fit their contents. |
AutoSizeColLabelSize |
Automatically adjusts width of the column to fit its label. |
AutoSizeColumn |
Automatically sizes the column to fit its contents. |
AutoSizeColumns |
Automatically sizes all columns to fit their contents. |
AutoSizeRow |
Automatically sizes the row to fit its contents. |
AutoSizeRowLabelSize |
Automatically adjusts height of the row to fit its label. |
AutoSizeRows |
Automatically sizes all rows to fit their contents. |
BeginBatch |
Increments the grid’s batch count. |
BlockToDeviceRect |
Convert grid cell coordinates to grid window pixel coordinates. |
CalcCellsExposed |
Appends one or more new columns to the right of the grid. |
CalcColLabelsExposed |
Appends one or more new columns to the right of the grid. |
CalcRowLabelsExposed |
Appends one or more new columns to the right of the grid. |
CanDragCell |
Return True if the dragging of cells is enabled or False otherwise. |
CanDragColMove |
Returns True if columns can be moved by dragging with the mouse. |
CanDragColSize |
Returns True if the given column can be resized by dragging with the mouse. |
CanDragGridSize |
Return True if the dragging of grid lines to resize rows and columns is enabled or False otherwise. |
CanDragRowSize |
Returns True if the given row can be resized by dragging with the mouse. |
CanEnableCellControl |
Returns True if the in-place edit control for the current grid cell can be used and False otherwise. |
CanHaveAttributes |
Returns True if this grid has support for cell attributes. |
CellToRect |
Return the rectangle corresponding to the grid cell’s size and position in logical coordinates. |
ClearGrid |
Clears all data in the underlying grid table and repaints the grid. |
ClearSelection |
Deselects all cells that are currently selected. |
ClipHorzGridLines |
Change whether the horizontal grid lines are clipped by the end of the last column. |
ClipVertGridLines |
Change whether the vertical grid lines are clipped by the end of the last row. |
Create |
Creates the grid window for an object initialized using the default constructor. |
CreateGrid |
Creates a grid with the specified initial number of rows and columns. |
DeleteCols |
Deletes one or more columns from a grid starting at the specified position. |
DeleteRows |
Deletes one or more rows from a grid starting at the specified position. |
DeselectCell |
Deselects a cell. |
DeselectCol |
Deselects a column of cells. |
DeselectRow |
Deselects a row of cells. |
DisableCellEditControl |
Disables in-place editing of grid cells. |
DisableColResize |
Disable interactive resizing of the specified column. |
DisableDragColMove |
Disables column moving by dragging with the mouse. |
DisableDragColSize |
Disables column sizing by dragging with the mouse. |
DisableDragGridSize |
Disable mouse dragging of grid lines to resize rows and columns. |
DisableDragRowSize |
Disables row sizing by dragging with the mouse. |
DisableRowResize |
Disable interactive resizing of the specified row. |
DrawCellHighlight |
|
DrawColLabel |
|
DrawColLabels |
|
DrawCornerLabel |
|
DrawRowLabel |
|
DrawRowLabels |
|
DrawTextRectangle |
|
EnableCellEditControl |
Enables or disables in-place editing of grid cell data. |
EnableDragCell |
Enables or disables cell dragging with the mouse. |
EnableDragColMove |
Enables or disables column moving by dragging with the mouse. |
EnableDragColSize |
Enables or disables column sizing by dragging with the mouse. |
EnableDragGridSize |
Enables or disables row and column resizing by dragging gridlines with the mouse. |
EnableDragRowSize |
Enables or disables row sizing by dragging with the mouse. |
EnableEditing |
Makes the grid globally editable or read-only. |
EnableGridLines |
Turns the drawing of grid lines on or off. |
EndBatch |
Decrements the grid’s batch count. |
Fit |
Overridden wx.Window method. |
ForceRefresh |
Causes immediate repainting of the grid. |
GetBatchCount |
Returns the number of times that BeginBatch has been called without (yet) matching calls to EndBatch . |
GetCellAlignment |
Sets the arguments to the horizontal and vertical text alignment values for the grid cell at the specified location. |
GetCellBackgroundColour |
Returns the background colour of the cell at the specified location. |
GetCellEditor |
Returns a pointer to the editor for the cell at the specified location. |
GetCellFont |
Returns the font for text in the grid cell at the specified location. |
GetCellHighlightColour |
|
GetCellHighlightPenWidth |
|
GetCellHighlightROPenWidth |
|
GetCellOverflow |
Returns True if the cell value can overflow. |
GetCellRenderer |
Returns a pointer to the renderer for the grid cell at the specified location. |
GetCellSize |
Get the size of the cell in number of cells covered by it. |
GetCellTextColour |
Returns the text colour for the grid cell at the specified location. |
GetCellValue |
Returns the string contained in the cell at the specified location. |
GetColAt |
Returns the column ID of the specified column position. |
GetColGridLinePen |
Returns the pen used for vertical grid lines. |
GetColLabelAlignment |
Sets the arguments to the current column label alignment values. |
GetColLabelSize |
Returns the current height of the column labels. |
GetColLabelTextOrientation |
Returns the orientation of the column labels (either HORIZONTAL or VERTICAL ). |
GetColLabelValue |
Returns the specified column label. |
GetColLeft |
Returns the coordinate of the left border specified column. |
GetColMinimalAcceptableWidth |
Returns the minimal width to which a column may be resized. |
GetColMinimalWidth |
Get the minimal width of the given column/row. |
GetColPos |
Returns the position of the specified column. |
GetColRight |
Returns the coordinate of the right border specified column. |
GetColSize |
Returns the width of the specified column. |
GetColSizes |
Get size information for all columns at once. |
GetDefaultCellAlignment |
Returns the default cell alignment. |
GetDefaultCellBackgroundColour |
Returns the current default background colour for grid cells. |
GetDefaultCellFont |
Returns the current default font for grid cell text. |
GetDefaultCellOverflow |
Returns True if the cells can overflow by default. |
GetDefaultCellTextColour |
Returns the current default colour for grid cell text. |
GetDefaultColLabelSize |
Returns the default height for column labels. |
GetDefaultColSize |
Returns the current default width for grid columns. |
GetDefaultEditor |
Returns a pointer to the current default grid cell editor. |
GetDefaultEditorForCell |
Returns the default editor for the specified cell. |
GetDefaultEditorForType |
Returns the default editor for the cells containing values of the given type. |
GetDefaultGridLinePen |
Returns the pen used for grid lines. |
GetDefaultRenderer |
Returns a pointer to the current default grid cell renderer. |
GetDefaultRendererForCell |
Returns the default renderer for the given cell. |
GetDefaultRendererForType |
Returns the default renderer for the cell containing values of the given type. |
GetDefaultRowLabelSize |
Returns the default width for the row labels. |
GetDefaultRowSize |
Returns the current default height for grid rows. |
GetGridColHeader |
Return the header control used for column labels display. |
GetGridColLabelWindow |
Return the column labels window. |
GetGridCornerLabelWindow |
Return the window in the top left grid corner. |
GetGridCursorCol |
Returns the current grid cell column position. |
GetGridCursorRow |
Returns the current grid cell row position. |
GetGridLineColour |
Returns the colour used for grid lines. |
GetGridRowLabelWindow |
Return the row labels window. |
GetGridWindow |
Return the main grid window containing the grid cells. |
GetLabelBackgroundColour |
Returns the colour used for the background of row and column labels. |
GetLabelFont |
Returns the font used for row and column labels. |
GetLabelTextColour |
Returns the colour used for row and column label text. |
GetNumberCols |
Returns the total number of grid columns. |
GetNumberRows |
Returns the total number of grid rows. |
GetOrCreateCellAttr |
Returns the attribute for the given cell creating one if necessary. |
GetRowGridLinePen |
Returns the pen used for horizontal grid lines. |
GetRowLabelAlignment |
Returns the alignment used for row labels. |
GetRowLabelSize |
Returns the current width of the row labels. |
GetRowLabelValue |
Returns the specified row label. |
GetRowMinimalAcceptableHeight |
Returns the minimal size to which rows can be resized. |
GetRowMinimalHeight |
Returns the minimal size for the given column. |
GetRowSize |
Returns the height of the specified row. |
GetRowSizes |
Get size information for all row at once. |
GetScrollLineX |
Returns the number of pixels per horizontal scroll increment. |
GetScrollLineY |
Returns the number of pixels per vertical scroll increment. |
GetSelectedCells |
Returns an array of individually selected cells. |
GetSelectedCols |
Returns an array of selected columns. |
GetSelectedRows |
Returns an array of selected rows. |
GetSelectionBackground |
Returns the colour used for drawing the selection background. |
GetSelectionBlockBottomRight |
Returns an array of the bottom right corners of blocks of selected cells. |
GetSelectionBlockTopLeft |
Returns an array of the top left corners of blocks of selected cells. |
GetSelectionForeground |
Returns the colour used for drawing the selection foreground. |
GetSelectionMode |
Returns the current selection mode. |
GetSortingColumn |
Return the column in which the sorting indicator is currently displayed. |
GetTable |
Returns a base pointer to the current table object. |
GoToCell |
Make the given cell current and ensure it is visible. |
GridLinesEnabled |
Returns True if drawing of grid lines is turned on, False otherwise. |
HideCellEditControl |
Hides the in-place cell edit control. |
HideCol |
Hides the specified column. |
HideColLabels |
Hides the column labels by calling SetColLabelSize with a size of 0. |
HideRow |
Hides the specified row. |
HideRowLabels |
Hides the row labels by calling SetRowLabelSize with a size of 0. |
InsertCols |
Inserts one or more new columns into a grid with the first new column at the specified position. |
InsertRows |
Inserts one or more new rows into a grid with the first new row at the specified position. |
IsCellEditControlEnabled |
Returns True if the in-place edit control is currently enabled. |
IsCellEditControlShown |
Returns True if the in-place edit control is currently shown. |
IsColShown |
Returns True if the specified column is not currently hidden. |
IsCurrentCellReadOnly |
Returns True if the current cell is read-only. |
IsEditable |
Returns False if the whole grid has been set as read-only or True otherwise. |
IsInSelection |
Returns True if the given cell is selected. |
IsReadOnly |
Returns True if the cell at the specified location can’t be edited. |
IsRowShown |
Returns True if the specified row is not currently hidden. |
IsSelection |
Returns True if there are currently any selected cells, rows, columns or blocks. |
IsSortOrderAscending |
Return True if the current sorting order is ascending or False if it is descending. |
IsSortingBy |
Return True if this column is currently used for sorting. |
IsVisible |
Returns True if a cell is either entirely or at least partially visible in the grid window. |
MakeCellVisible |
Brings the specified cell into the visible grid cell area with minimal scrolling. |
MoveCursorDown |
Moves the grid cursor down by one row. |
MoveCursorDownBlock |
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. |
MoveCursorLeft |
Moves the grid cursor left by one column. |
MoveCursorLeftBlock |
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. |
MoveCursorRight |
Moves the grid cursor right by one column. |
MoveCursorRightBlock |
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. |
MoveCursorUp |
Moves the grid cursor up by one row. |
MoveCursorUpBlock |
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. |
MovePageDown |
Moves the grid cursor down by some number of rows so that the previous bottom visible row becomes the top visible row. |
MovePageUp |
Moves the grid cursor up by some number of rows so that the previous top visible row becomes the bottom visible row. |
ProcessTableMessage |
Receive and handle a message from the table. |
RefreshAttr |
Invalidates the cached attribute for the given cell. |
RegisterDataType |
Register a new data type. |
Render |
Draws part or all of a wx.grid.Grid on a wx.DC for printing or display. |
ResetColPos |
Resets the position of the columns to the default. |
SaveEditControlValue |
Sets the value of the current grid cell to the current in-place edit control value. |
SelectAll |
Selects all cells in the grid. |
SelectBlock |
Selects a rectangular block of cells. |
SelectCol |
Selects the specified column. |
SelectRow |
Selects the specified row. |
SetAttr |
Sets the cell attributes for the specified cell. |
SetCellAlignment |
Sets the horizontal and vertical alignment for grid cell text at the specified location. |
SetCellBackgroundColour |
Set the background colour for the given cell or all cells by default. |
SetCellEditor |
Sets the editor for the grid cell at the specified location. |
SetCellFont |
Sets the font for text in the grid cell at the specified location. |
SetCellHighlightColour |
|
SetCellHighlightPenWidth |
|
SetCellHighlightROPenWidth |
|
SetCellOverflow |
Sets the overflow permission of the cell. |
SetCellRenderer |
Sets the renderer for the grid cell at the specified location. |
SetCellSize |
Set the size of the cell. |
SetCellTextColour |
Sets the text colour for the given cell. |
SetCellValue |
Sets the string value for the cell at the specified location. |
SetColAttr |
Sets the cell attributes for all cells in the specified column. |
SetColFormatBool |
Sets the specified column to display boolean values. |
SetColFormatCustom |
Sets the specified column to display data in a custom format. |
SetColFormatFloat |
Sets the specified column to display floating point values with the given width and precision. |
SetColFormatNumber |
Sets the specified column to display integer values. |
SetColLabelAlignment |
Sets the horizontal and vertical alignment of column label text. |
SetColLabelSize |
Sets the height of the column labels. |
SetColLabelTextOrientation |
Sets the orientation of the column labels (either HORIZONTAL or VERTICAL ). |
SetColLabelValue |
Set the value for the given column label. |
SetColMinimalAcceptableWidth |
Sets the minimal width to which the user can resize columns. |
SetColMinimalWidth |
Sets the minimal width for the specified column col. |
SetColPos |
Sets the position of the specified column. |
SetColSize |
Sets the width of the specified column. |
SetColSizes |
Restore all columns sizes. |
SetColumnsOrder |
Sets the positions of all columns at once. |
SetDefaultCellAlignment |
Sets the default horizontal and vertical alignment for grid cell text. |
SetDefaultCellBackgroundColour |
Sets the default background colour for grid cells. |
SetDefaultCellFont |
Sets the default font to be used for grid cell text. |
SetDefaultCellOverflow |
Sets the default overflow permission of the cells. |
SetDefaultCellTextColour |
Sets the current default colour for grid cell text. |
SetDefaultColSize |
Sets the default width for columns in the grid. |
SetDefaultEditor |
Sets the default editor for grid cells. |
SetDefaultRenderer |
Sets the default renderer for grid cells. |
SetDefaultRowSize |
Sets the default height for rows in the grid. |
SetGridCursor |
Set the grid cursor to the specified cell. |
SetGridLineColour |
Sets the colour used to draw grid lines. |
SetLabelBackgroundColour |
Sets the background colour for row and column labels. |
SetLabelFont |
Sets the font for row and column labels. |
SetLabelTextColour |
Sets the colour for row and column label text. |
SetMargins |
Sets the extra margins used around the grid area. |
SetReadOnly |
Makes the cell at the specified location read-only or editable. |
SetRowAttr |
Sets the cell attributes for all cells in the specified row. |
SetRowLabelAlignment |
Sets the horizontal and vertical alignment of row label text. |
SetRowLabelSize |
Sets the width of the row labels. |
SetRowLabelValue |
Sets the value for the given row label. |
SetRowMinimalAcceptableHeight |
Sets the minimal row height used by default. |
SetRowMinimalHeight |
Sets the minimal height for the specified row. |
SetRowSize |
Sets the height of the specified row. |
SetRowSizes |
Restore all rows sizes. |
SetScrollLineX |
Sets the number of pixels per horizontal scroll increment. |
SetScrollLineY |
Sets the number of pixels per vertical scroll increment. |
SetSelectionBackground |
Set the colour to be used for drawing the selection background. |
SetSelectionForeground |
Set the colour to be used for drawing the selection foreground. |
SetSelectionMode |
Set the selection behaviour of the grid. |
SetSortingColumn |
Set the column to display the sorting indicator in and its direction. |
SetTabBehaviour |
Set the grid’s behaviour when the user presses the TAB key. |
_SetTable |
Passes a pointer to a custom grid table to be used by the grid. |
SetTable |
Set the Grid Table to be used by this grid. |
SetUseNativeColLabels |
Call this in order to make the column labels use a native look by using wx.RendererNative.DrawHeaderButton internally. |
ShowCellEditControl |
Displays the in-place cell edit control for the current cell. |
ShowCol |
Shows the previously hidden column by resizing it to non-0 size. |
ShowRow |
Shows the previously hidden row. |
UnsetSortingColumn |
Remove any currently shown sorting indicator. |
UseNativeColHeader |
Enable the use of native header window for column labels. |
XToCol |
Returns the column at the given pixel position. |
XToEdgeOfCol |
Returns the column whose right hand edge is close to the given logical x position. |
XYToCell |
Translates logical pixel coordinates to the grid cell coordinates. |
YToEdgeOfRow |
Returns the row whose bottom edge is close to the given logical y position. |
YToRow |
Returns the grid row that corresponds to the logical y coordinate. |
wx.grid.
Grid
(ScrolledWindow)¶Possible constructors:
Grid()
Grid(parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize,
style=WANTS_CHARS, name=GridNameStr)
Grid and its related classes are used for displaying and editing tabular data.
__init__
(self, *args, **kw)¶__init__ (self)
Default constructor.
You must call Create
to really create the grid window and also call CreateGrid
or SetTable
to initialize the grid contents.
__init__ (self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=WANTS_CHARS, name=GridNameStr)
Constructor creating the grid window.
You must call either CreateGrid
or SetTable
to initialize the grid contents before using it.
Parameters: |
---|
AppendCols
(self, numCols=1, updateLabels=True)¶Appends one or more new columns to the right of the grid.
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: |
|
---|---|
Return type: | bool |
Returns: |
|
AppendRows
(self, numRows=1, updateLabels=True)¶Appends one or more new rows to the bottom of the grid.
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: |
|
---|---|
Return type: | bool |
Returns: |
|
AreHorzGridLinesClipped
(self)¶Return True
if the horizontal grid lines stop at the last column boundary or False
if they continue to the end of the window.
The default is to clip grid lines.
Return type: | bool |
---|
See also
AreVertGridLinesClipped
(self)¶Return True
if the vertical grid lines stop at the last row boundary or False
if they continue to the end of the window.
The default is to clip grid lines.
Return type: | bool |
---|
See also
AutoSize
(self)¶Automatically sets the height and width of all rows and columns to fit their contents.
AutoSizeColLabelSize
(self, col)¶Automatically adjusts width of the column to fit its label.
Parameters: | col (int) – |
---|
AutoSizeColumn
(self, col, setAsMin=True)¶Automatically sizes the column to fit its contents.
If setAsMin is True
the calculated width will also be set as the minimal width for the column.
Parameters: |
|
---|
AutoSizeColumns
(self, setAsMin=True)¶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: | setAsMin (bool) – |
---|
AutoSizeRow
(self, row, setAsMin=True)¶Automatically sizes the row to fit its contents.
If setAsMin is True
the calculated height will also be set as the minimal height for the row.
Parameters: |
|
---|
AutoSizeRowLabelSize
(self, col)¶Automatically adjusts height of the row to fit its label.
Parameters: | col (int) – |
---|
AutoSizeRows
(self, setAsMin=True)¶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: | setAsMin (bool) – |
---|
BeginBatch
(self)¶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
call will cause the grid to be repainted.
Notice that you should use wx.grid.GridUpdateLocker which ensures that there is always a matching EndBatch
call for this BeginBatch
if possible instead of calling this method directly.
BlockToDeviceRect
(self, topLeft, bottomRight)¶Convert grid cell coordinates to grid window pixel coordinates.
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: |
|
---|---|
Return type: |
|
See also
CalcCellsExposed
(self, reg)¶Appends one or more new columns to the right of the grid.
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: | reg (wx.Region) – |
---|---|
Return type: | GridCellCoordsArray |
Returns: | True on success or False if appending columns failed. |
CalcColLabelsExposed
(self, reg)¶Appends one or more new columns to the right of the grid.
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: | reg (wx.Region) – |
---|---|
Return type: | list of integers |
Returns: | True on success or False if appending columns failed. |
CalcRowLabelsExposed
(self, reg)¶Appends one or more new columns to the right of the grid.
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: | reg (wx.Region) – |
---|---|
Return type: | list of integers |
Returns: | True on success or False if appending columns failed. |
CanDragCell
(self)¶Return True
if the dragging of cells is enabled or False
otherwise.
Return type: | bool |
---|
CanDragColMove
(self)¶Returns True
if columns can be moved by dragging with the mouse.
Columns can be moved by dragging on their labels.
Return type: | bool |
---|
CanDragColSize
(self, col)¶Returns True
if the given column can be resized by dragging with the mouse.
This function returns True
if resizing the columns interactively is globally enabled, i.e. if DisableDragColSize
hadn’t been called, and if this column wasn’t explicitly marked as non-resizable with DisableColResize
.
Parameters: | col (int) – |
---|---|
Return type: | bool |
CanDragGridSize
(self)¶Return True
if the dragging of grid lines to resize rows and columns is enabled or False
otherwise.
Return type: | bool |
---|
CanDragRowSize
(self, row)¶Returns True
if the given row can be resized by dragging with the mouse.
This is the same as CanDragColSize
but for rows.
Parameters: | row (int) – |
---|---|
Return type: | bool |
CanEnableCellControl
(self)¶Returns True
if the in-place edit control for the current grid cell can be used and False
otherwise.
This function always returns False
for the read-only cells.
Return type: | bool |
---|
CanHaveAttributes
(self)¶Returns True
if this grid has support for cell attributes.
The grid supports attributes if it has the associated table which, in turn, has attributes support, i.e. wx.grid.GridTableBase.CanHaveAttributes
returns True
.
Return type: | bool |
---|
CellToRect
(self, *args, **kw)¶Return the rectangle corresponding to the grid cell’s size and position in logical coordinates.
See also
CellToRect (self, row, col)
Parameters: |
|
---|---|
Return type: |
|
CellToRect (self, coords)
Parameters: | coords (wx.grid.GridCellCoords) – |
---|---|
Return type: | Rect |
ClearGrid
(self)¶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.
ClearSelection
(self)¶Deselects all cells that are currently selected.
ClipHorzGridLines
(self, clip)¶Change whether the horizontal grid lines are clipped by the end of the last column.
By default the grid lines are not drawn beyond the end of the last column but after calling this function with clip set to False
they will be drawn across the entire grid window.
Parameters: | clip (bool) – |
---|
See also
ClipVertGridLines
(self, clip)¶Change whether the vertical grid lines are clipped by the end of the last row.
By default the grid lines are not drawn beyond the end of the last row but after calling this function with clip set to False
they will be drawn across the entire grid window.
Parameters: | clip (bool) – |
---|
See also
Create
(self, parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=WANTS_CHARS, name=GridNameStr)¶Creates the grid window for an object initialized using the default constructor.
You must call either CreateGrid
or SetTable
to initialize the grid contents before using it.
Parameters: | |
---|---|
Return type: | bool |
CreateGrid
(self, numRows, numCols, selmode=GridSelectCells)¶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.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: |
|
---|---|
Return type: | bool |
DeleteCols
(self, pos=0, numCols=1, updateLabels=True)¶Deletes one or more columns from a grid starting at the specified position.
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: |
|
---|---|
Return type: | bool |
Returns: |
|
DeleteRows
(self, pos=0, numRows=1, updateLabels=True)¶Deletes one or more rows from a grid starting at the specified position.
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: |
|
---|---|
Return type: | bool |
Returns: |
|
DeselectCell
(self, row, col)¶Deselects a cell.
Parameters: |
|
---|
DeselectCol
(self, col)¶Deselects a column of cells.
Parameters: | col (int) – |
---|
DeselectRow
(self, row)¶Deselects a row of cells.
Parameters: | row (int) – |
---|
DisableCellEditControl
(self)¶Disables in-place editing of grid cells.
Equivalent to calling EnableCellEditControl(false).
DisableColResize
(self, col)¶Disable interactive resizing of the specified column.
This method allows to disable resizing of an individual column in a grid where the columns are otherwise resizable (which is the case by default).
Notice that currently there is no way to make some columns resizable in a grid where columns can’t be resized by default as there doesn’t seem to be any need for this in practice. There is also no way to make the column marked as fixed using this method resizable again because it is supposed that fixed columns are used for static parts of the grid and so should remain fixed during the entire grid lifetime.
Also notice that disabling interactive column resizing will not prevent the program from changing the column size.
Parameters: | col (int) – |
---|
See also
DisableDragColMove
(self)¶Disables column moving by dragging with the mouse.
Equivalent to passing False
to EnableDragColMove
.
DisableDragColSize
(self)¶Disables column sizing by dragging with the mouse.
Equivalent to passing False
to EnableDragColSize
.
DisableDragGridSize
(self)¶Disable mouse dragging of grid lines to resize rows and columns.
Equivalent to passing False
to EnableDragGridSize
DisableDragRowSize
(self)¶Disables row sizing by dragging with the mouse.
Equivalent to passing False
to EnableDragRowSize
.
DisableRowResize
(self, row)¶Disable interactive resizing of the specified row.
This is the same as DisableColResize
but for rows.
Parameters: | row (int) – |
---|
See also
DrawCellHighlight
(self, dc, attr)¶Parameters: |
|
---|
DrawTextRectangle
(self, *args, **kw)¶DrawTextRectangle (self, dc, text, rect, horizontalAlignment=ALIGN_LEFT, verticalAlignment=ALIGN_TOP, textOrientation=HORIZONTAL)
Parameters: |
---|
DrawTextRectangle (self, dc, lines, rect, horizontalAlignment=ALIGN_LEFT, verticalAlignment=ALIGN_TOP, textOrientation=HORIZONTAL)
Parameters: |
---|
EnableCellEditControl
(self, enable=True)¶Enables or disables in-place editing of grid cell data.
The grid will issue either a wxEVT_GRID_EDITOR_SHOWN
or wxEVT_GRID_EDITOR_HIDDEN
event.
Parameters: | enable (bool) – |
---|
EnableDragCell
(self, enable=True)¶Enables or disables cell dragging with the mouse.
Parameters: | enable (bool) – |
---|
EnableDragColMove
(self, enable=True)¶Enables or disables column moving by dragging with the mouse.
Parameters: | enable (bool) – |
---|
EnableDragColSize
(self, enable=True)¶Enables or disables column sizing by dragging with the mouse.
Parameters: | enable (bool) – |
---|
See also
EnableDragGridSize
(self, enable=True)¶Enables or disables row and column resizing by dragging gridlines with the mouse.
Parameters: | enable (bool) – |
---|
EnableDragRowSize
(self, enable=True)¶Enables or disables row sizing by dragging with the mouse.
Parameters: | enable (bool) – |
---|
See also
EnableEditing
(self, edit)¶Makes the grid globally editable or read-only.
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.GridCellAttr.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 class and the Grid Overview.
Parameters: | edit (bool) – |
---|
EnableGridLines
(self, enable=True)¶Turns the drawing of grid lines on or off.
Parameters: | enable (bool) – |
---|
EndBatch
(self)¶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.
See also
ForceRefresh
(self)¶Causes immediate repainting of the grid.
Use this instead of the usual wx.Window.Refresh
.
GetBatchCount
(self)¶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.
Return type: | int |
---|
GetCellAlignment
(self, row, col)¶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 ALIGN_LEFT
, ALIGN_CENTRE
or ALIGN_RIGHT
.
Vertical alignment will be one of ALIGN_TOP
, ALIGN_CENTRE
or ALIGN_BOTTOM
.
Parameters: |
|
---|---|
Return type: | tuple |
Returns: | ( horiz, vert ) |
GetCellBackgroundColour
(self, row, col)¶Returns the background colour of the cell at the specified location.
Parameters: |
|
---|---|
Return type: | Colour |
GetCellEditor
(self, row, col)¶Returns a pointer to the editor for the cell at the specified location.
See wx.grid.GridCellEditor and the Grid Overview for more information about cell editors and renderers.
The caller must call DecRef() on the returned pointer.
Parameters: |
|
---|---|
Return type: |
GetCellFont
(self, row, col)¶Returns the font for text in the grid cell at the specified location.
Parameters: |
|
---|---|
Return type: |
|
GetCellHighlightColour
(self)¶Return type: | Colour |
---|
GetCellHighlightPenWidth
(self)¶Return type: | int |
---|
GetCellHighlightROPenWidth
(self)¶Return type: | int |
---|
GetCellOverflow
(self, row, col)¶Returns True
if the cell value can overflow.
A cell can overflow if the next cell in the row is empty.
Parameters: |
|
---|---|
Return type: | bool |
GetCellRenderer
(self, row, col)¶Returns a pointer to the renderer for the grid cell at the specified location.
See wx.grid.GridCellRenderer and the Grid Overview for more information about cell editors and renderers.
The caller must call DecRef() on the returned pointer.
Parameters: |
|
---|---|
Return type: |
GetCellSize
(self, *args, **kw)¶GetCellSize (self, row, col, num_rows, num_cols)
Get the size of the cell in number of cells covered by it.
For normal cells, the function fills both num_rows and num_cols with 1 and returns CellSpan_None. For cells which span multiple cells, i.e. for which SetCellSize
had been called, the returned values are the same ones as were passed to SetCellSize
call and the function return value is CellSpan_Main.
More unexpectedly, perhaps, the returned values may be negative for the cells which are inside a span covered by a cell occupying multiple rows or columns. They correspond to the offset of the main cell of the span from the cell passed to this functions and the function returns CellSpan_Inside value to indicate this.
As an example, consider a 3x3 grid with the cell (1, 1) (the one in the middle) having a span of 2 rows and 2 columns, i.e. the grid looks like
+----+----+----+
| | | |
+----+----+----+
| | |
+----+ |
| | |
+----+----+----+
Then the function returns 2 and 2 in num_rows and num_cols for the cell (1, 1) itself and -1 and -1 for the cell (2, 2) as well as -1 and 0 for the cell (2, 1).
Parameters: |
|
---|---|
Return type: | |
Returns: | The kind of this cell span (the return value is new in wxWidgets 2.9.1, this function was in previous wxWidgets versions). |
GetCellSize (self, coords)
Get the number of rows and columns allocated for this cell.
This overload doesn’t return a CellSpan value but the values returned may still be negative, see GetCellSize(int, int, int, int ) for details.
Parameters: | coords (wx.grid.GridCellCoords) – |
---|---|
Return type: | Size |
GetCellTextColour
(self, row, col)¶Returns the text colour for the grid cell at the specified location.
Parameters: |
|
---|---|
Return type: | Colour |
GetCellValue
(self, *args, **kw)¶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
and the Grid Overview for more information.
GetCellValue (self, row, col)
Parameters: |
|
---|---|
Return type: |
|
GetCellValue (self, coords)
Parameters: | coords (wx.grid.GridCellCoords) – |
---|---|
Return type: | string |
GetColAt
(self, colPos)¶Returns the column ID
of the specified column position.
Parameters: | colPos (int) – |
---|---|
Return type: | int |
GetColGridLinePen
(self, col)¶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: | col (int) – |
---|---|
Return type: | Pen |
GetColLabelAlignment
(self)¶Sets the arguments to the current column label alignment values.
Horizontal alignment will be one of ALIGN_LEFT
, ALIGN_CENTRE
or ALIGN_RIGHT
.
Vertical alignment will be one of ALIGN_TOP
, ALIGN_CENTRE
or ALIGN_BOTTOM
.
Return type: | tuple |
---|---|
Returns: | ( horiz, vert ) |
GetColLabelSize
(self)¶Returns the current height of the column labels.
Return type: | int |
---|
GetColLabelTextOrientation
(self)¶Returns the orientation of the column labels (either HORIZONTAL
or VERTICAL
).
Return type: | int |
---|
GetColLabelValue
(self, col)¶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: | col (int) – |
---|---|
Return type: | string |
GetColLeft
(self, col)¶Returns the coordinate of the left border specified column.
Parameters: | col (int) – |
---|---|
Return type: | int |
GetColMinimalAcceptableWidth
(self)¶Returns the minimal width to which a column may be resized.
Use SetColMinimalAcceptableWidth
to change this value globally or SetColMinimalWidth
to do it for individual columns.
Return type: | int |
---|
See also
GetColMinimalWidth
(self, col)¶Get the minimal width of the given column/row.
The value returned by this function may be different than that returned by GetColMinimalAcceptableWidth
if SetColMinimalWidth
had been called for this column.
Parameters: | col (int) – |
---|---|
Return type: | int |
GetColPos
(self, colID)¶Returns the position of the specified column.
Parameters: | colID (int) – |
---|---|
Return type: | int |
GetColRight
(self, col)¶Returns the coordinate of the right border specified column.
Parameters: | col (int) – |
---|---|
Return type: | int |
GetColSize
(self, col)¶Returns the width of the specified column.
Parameters: | col (int) – |
---|---|
Return type: | int |
GetColSizes
(self)¶Get size information for all columns at once.
This method is useful when the information about all column widths needs to be saved. The widths can be later restored using SetColSizes
.
Return type: | wx.grid.GridSizesInfo |
---|
See also
GetDefaultCellAlignment
(self)¶Returns the default cell alignment.
Horizontal alignment will be one of ALIGN_LEFT
, ALIGN_CENTRE
or ALIGN_RIGHT
.
Vertical alignment will be one of ALIGN_TOP
, ALIGN_CENTRE
or ALIGN_BOTTOM
.
Return type: | tuple |
---|---|
Returns: | ( horiz, vert ) |
See also
GetDefaultCellBackgroundColour
(self)¶Returns the current default background colour for grid cells.
Return type: | Colour |
---|
GetDefaultCellFont
(self)¶Returns the current default font for grid cell text.
Return type: | Font |
---|
GetDefaultCellOverflow
(self)¶Returns True
if the cells can overflow by default.
Return type: | bool |
---|
GetDefaultCellTextColour
(self)¶Returns the current default colour for grid cell text.
Return type: | Colour |
---|
GetDefaultColLabelSize
(self)¶Returns the default height for column labels.
Return type: | int |
---|
GetDefaultColSize
(self)¶Returns the current default width for grid columns.
Return type: | int |
---|
GetDefaultEditor
(self)¶Returns a pointer to the current default grid cell editor.
See wx.grid.GridCellEditor and the Grid Overview for more information about cell editors and renderers.
Return type: | wx.grid.GridCellEditor |
---|
GetDefaultEditorForCell
(self, *args, **kw)¶Returns the default editor for the specified cell.
The base class version returns the editor appropriate for the current cell type but this method may be overridden in the derived classes to use custom editors for some cells by default.
Notice that the same may be achieved in a usually simpler way by associating a custom editor with the given cell or cells.
The caller must call DecRef() on the returned pointer.
GetDefaultEditorForCell (self, row, col)
Parameters: |
|
---|---|
Return type: |
GetDefaultEditorForCell (self, c)
Parameters: | c (wx.grid.GridCellCoords) – |
---|---|
Return type: | wx.grid.GridCellEditor |
GetDefaultEditorForType
(self, typeName)¶Returns the default editor for the cells containing values of the given type.
The base class version returns the editor which was associated with the specified typeName when it was registered RegisterDataType
but this function may be overridden to return something different. This allows to override an editor used for one of the standard types.
The caller must call DecRef() on the returned pointer.
Parameters: | typeName (string) – |
---|---|
Return type: | wx.grid.GridCellEditor |
GetDefaultGridLinePen
(self)¶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. Note that currently the pen width must be 1.
Return type: | Pen |
---|
See also
GetDefaultRenderer
(self)¶Returns a pointer to the current default grid cell renderer.
See wx.grid.GridCellRenderer and the Grid Overview for more information about cell editors and renderers.
The caller must call DecRef() on the returned pointer.
Return type: | wx.grid.GridCellRenderer |
---|
GetDefaultRendererForCell
(self, row, col)¶Returns the default renderer for the given cell.
The base class version returns the renderer appropriate for the current cell type but this method may be overridden in the derived classes to use custom renderers for some cells by default.
The caller must call DecRef() on the returned pointer.
Parameters: |
|
---|---|
Return type: |
GetDefaultRendererForType
(self, typeName)¶Returns the default renderer for the cell containing values of the given type.
Parameters: | typeName (string) – |
---|---|
Return type: | wx.grid.GridCellRenderer |
See also
GetDefaultRowLabelSize
(self)¶Returns the default width for the row labels.
Return type: | int |
---|
GetDefaultRowSize
(self)¶Returns the current default height for grid rows.
Return type: | int |
---|
GetGridColHeader
(self)¶Return the header control used for column labels display.
This function can only be called if UseNativeColHeader
had been called.
Return type: | HeaderCtrl |
---|
GetGridColLabelWindow
(self)¶Return the column labels window.
This window is not shown if the columns labels were hidden using HideColLabels
.
Depending on whether UseNativeColHeader
was called or not this can be either a wx.HeaderCtrl or a plain wx.Window. This function returns a valid window pointer in either case but in the former case you can also use GetGridColHeader
to access it if you need HeaderCtrl-specific functionality.
Return type: | Window |
---|
GetGridCornerLabelWindow
(self)¶Return the window in the top left grid corner.
This window is shown only of both columns and row labels are shown and normally doesn’t contain anything. Clicking on it is handled by wx.grid.Grid however and can be used to select the entire grid.
Return type: | Window |
---|
GetGridCursorCol
(self)¶Returns the current grid cell column position.
Return type: | int |
---|
GetGridCursorRow
(self)¶Returns the current grid cell row position.
Return type: | int |
---|
GetGridLineColour
(self)¶Returns the colour used for grid lines.
Return type: | Colour |
---|
See also
GetGridRowLabelWindow
(self)¶Return the row labels window.
This window is not shown if the row labels were hidden using HideRowLabels
.
Return type: | Window |
---|
GetGridWindow
(self)¶Return the main grid window containing the grid cells.
This window is always shown.
Return type: | Window |
---|
GetLabelBackgroundColour
(self)¶Returns the colour used for the background of row and column labels.
Return type: | Colour |
---|
GetLabelFont
(self)¶Returns the font used for row and column labels.
Return type: | Font |
---|
GetLabelTextColour
(self)¶Returns the colour used for row and column label text.
Return type: | Colour |
---|
GetNumberCols
(self)¶Returns the total number of grid columns.
This is the same as the number of columns in the underlying grid table.
Return type: | int |
---|
GetNumberRows
(self)¶Returns the total number of grid rows.
This is the same as the number of rows in the underlying grid table.
Return type: | int |
---|
GetOrCreateCellAttr
(self, row, col)¶Returns the attribute for the given cell creating one if necessary.
If the cell already has an attribute, it is returned. Otherwise a new attribute is created, associated with the cell and returned. In any case the caller must call DecRef() on the returned pointer.
This function may only be called if CanHaveAttributes
returns True
.
Parameters: |
|
---|---|
Return type: |
GetRowGridLinePen
(self, row)¶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.
Example:
# in a grid displaying music notation, use a solid black pen between
# octaves (C0=row 127, C1=row 115 etc.)
def GetRowGridLinePen(self, row):
if row % 12 == 7:
return wx.Pen(wx.BLACK, 1, wx.SOLID)
else:
return self.GetDefaultGridLinePen()
Parameters: | row (int) – |
---|---|
Return type: | Pen |
GetRowLabelAlignment
(self)¶Returns the alignment used for row labels.
Horizontal alignment will be one of ALIGN_LEFT
, ALIGN_CENTRE
or ALIGN_RIGHT
.
Vertical alignment will be one of ALIGN_TOP
, ALIGN_CENTRE
or ALIGN_BOTTOM
.
Return type: | tuple |
---|---|
Returns: | ( horiz, vert ) |
GetRowLabelSize
(self)¶Returns the current width of the row labels.
Return type: | int |
---|
GetRowLabelValue
(self, row)¶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: | row (int) – |
---|---|
Return type: | string |
GetRowMinimalAcceptableHeight
(self)¶Returns the minimal size to which rows can be resized.
Use SetRowMinimalAcceptableHeight
to change this value globally or SetRowMinimalHeight
to do it for individual cells.
Return type: | int |
---|
See also
GetRowMinimalHeight
(self, col)¶Returns the minimal size for the given column.
The value returned by this function may be different than that returned by GetRowMinimalAcceptableHeight
if SetRowMinimalHeight
had been called for this row.
Parameters: | col (int) – |
---|---|
Return type: | int |
GetRowSize
(self, row)¶Returns the height of the specified row.
Parameters: | row (int) – |
---|---|
Return type: | int |
GetRowSizes
(self)¶Get size information for all row at once.
Return type: | wx.grid.GridSizesInfo |
---|
See also
GetScrollLineX
(self)¶Returns the number of pixels per horizontal scroll increment.
The default is 15.
Return type: | int |
---|
See also
GetScrollLineY
(self)¶Returns the number of pixels per vertical scroll increment.
The default is 15.
Return type: | int |
---|
See also
GetSelectedCells
(self)¶Returns an array of individually selected cells.
Notice that this array does not contain all the selected cells in general as it doesn’t include the cells selected as part of column, row or block selection. You must use this method, GetSelectedCols
, GetSelectedRows
and GetSelectionBlockTopLeft
and GetSelectionBlockBottomRight
methods to obtain the entire selection in general.
Please notice this behaviour is by design and is needed in order to support grids of arbitrary size (when an entire column is selected in a grid with a million of columns, we don’t want to create an array with a million of entries in this function, instead it returns an empty array and GetSelectedCols
returns an array containing one element).
Return type: | GridCellCoordsArray |
---|
GetSelectedCols
(self)¶Returns an array of selected columns.
Please notice that this method alone is not sufficient to find all the selected columns as it contains only the columns which were individually selected but not those being part of the block selection or being selected in virtue of all of their cells being selected individually, please see GetSelectedCells
for more details.
Return type: | list of integers |
---|
GetSelectedRows
(self)¶Returns an array of selected rows.
Please notice that this method alone is not sufficient to find all the selected rows as it contains only the rows which were individually selected but not those being part of the block selection or being selected in virtue of all of their cells being selected individually, please see GetSelectedCells
for more details.
Return type: | list of integers |
---|
GetSelectionBackground
(self)¶Returns the colour used for drawing the selection background.
Return type: | Colour |
---|
GetSelectionBlockBottomRight
(self)¶Returns an array of the bottom right corners of blocks of selected cells.
Please see GetSelectedCells
for more information about the selection representation in wx.grid.Grid.
Return type: | GridCellCoordsArray |
---|
See also
GetSelectionBlockTopLeft
(self)¶Returns an array of the top left corners of blocks of selected cells.
Please see GetSelectedCells
for more information about the selection representation in wx.grid.Grid.
Return type: | GridCellCoordsArray |
---|
See also
GetSelectionForeground
(self)¶Returns the colour used for drawing the selection foreground.
Return type: | Colour |
---|
GetSelectionMode
(self)¶Returns the current selection mode.
Return type: | wx.grid.Grid.GridSelectionModes |
---|
See also
GetSortingColumn
(self)¶Return the column in which the sorting indicator is currently displayed.
Returns NOT_FOUND
if sorting indicator is not currently displayed at all.
Return type: | int |
---|
See also
GetTable
(self)¶Returns a base pointer to the current table object.
The returned pointer is still owned by the grid.
Return type: | wx.grid.GridTableBase |
---|
GoToCell
(self, *args, **kw)¶Make the given cell current and ensure it is visible.
This method is equivalent to calling MakeCellVisible
and SetGridCursor
and so, as with the latter, a wxEVT_GRID_SELECT_CELL
event is generated by it and the selected cell doesn’t change if the event is vetoed.
GoToCell (self, row, col)
Parameters: |
|
---|
GoToCell (self, coords)
Parameters: | coords (wx.grid.GridCellCoords) – |
---|
GridLinesEnabled
(self)¶Returns True
if drawing of grid lines is turned on, False
otherwise.
Return type: | bool |
---|
HideCellEditControl
(self)¶Hides the in-place cell edit control.
HideCol
(self, col)¶Hides the specified column.
To show the column later you need to call SetColSize
with non-0 width or ShowCol
to restore the previous column width.
If the column is already hidden, this method doesn’t do anything.
Parameters: | col (int) – The column index. |
---|
HideColLabels
(self)¶Hides the column labels by calling SetColLabelSize
with a size of 0.
Show labels again by calling that method with a width greater than 0.
HideRow
(self, col)¶Hides the specified row.
To show the row later you need to call SetRowSize
with non-0 width or ShowRow
to restore its original height.
If the row is already hidden, this method doesn’t do anything.
Parameters: | col (int) – The row index. |
---|
HideRowLabels
(self)¶Hides the row labels by calling SetRowLabelSize
with a size of 0.
The labels can be shown again by calling SetRowLabelSize
with a width greater than 0.
InsertCols
(self, pos=0, numCols=1, updateLabels=True)¶Inserts one or more new columns into a grid with the first new column at the specified position.
Notice that inserting the columns in the grid requires grid table cooperation: when this method is called, grid object begins by 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: |
|
---|---|
Return type: | bool |
Returns: |
|
InsertRows
(self, pos=0, numRows=1, updateLabels=True)¶Inserts one or more new rows into a grid with the first new row at the specified position.
Notice that you must implement wx.grid.GridTableBase.InsertRows
if you use a grid with a custom table, please see InsertCols
for more information.
Parameters: |
|
---|---|
Return type: | bool |
Returns: |
|
IsCellEditControlEnabled
(self)¶Returns True
if the in-place edit control is currently enabled.
Return type: | bool |
---|
IsCellEditControlShown
(self)¶Returns True
if the in-place edit control is currently shown.
Return type: | bool |
---|
See also
IsColShown
(self, col)¶Returns True
if the specified column is not currently hidden.
Parameters: | col (int) – |
---|---|
Return type: | bool |
IsCurrentCellReadOnly
(self)¶Returns True
if the current cell is read-only.
Return type: | bool |
---|
See also
IsEditable
(self)¶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.
Return type: | bool |
---|
IsInSelection
(self, *args, **kw)¶Returns True
if the given cell is selected.
IsInSelection (self, row, col)
Parameters: |
|
---|---|
Return type: | bool |
IsInSelection (self, coords)
Parameters: | coords (wx.grid.GridCellCoords) – |
---|---|
Return type: | bool |
IsReadOnly
(self, row, col)¶Returns True
if the cell at the specified location can’t be edited.
Parameters: |
|
---|---|
Return type: | bool |
See also
IsRowShown
(self, row)¶Returns True
if the specified row is not currently hidden.
Parameters: | row (int) – |
---|---|
Return type: | bool |
IsSelection
(self)¶Returns True
if there are currently any selected cells, rows, columns or blocks.
Return type: | bool |
---|
IsSortOrderAscending
(self)¶Return True
if the current sorting order is ascending or False
if it is descending.
It only makes sense to call this function if GetSortingColumn
returns a valid column index and not NOT_FOUND
.
Return type: | bool |
---|
See also
IsSortingBy
(self, col)¶Return True
if this column is currently used for sorting.
Parameters: | col (int) – |
---|---|
Return type: | bool |
See also
IsVisible
(self, *args, **kw)¶Returns True
if a cell is either entirely or at least partially visible in the grid window.
By default, the cell must be entirely visible for this function to return True
but if wholeCellVisible is False
, the function returns True
even if the cell is only partially visible.
IsVisible (self, row, col, wholeCellVisible=True)
Parameters: |
|
---|---|
Return type: | bool |
IsVisible (self, coords, wholeCellVisible=True)
Parameters: |
|
---|---|
Return type: | bool |
MakeCellVisible
(self, *args, **kw)¶Brings the specified cell into the visible grid cell area with minimal scrolling.
Does nothing if the cell is already visible.
MakeCellVisible (self, row, col)
Parameters: |
|
---|
MakeCellVisible (self, coords)
Parameters: | coords (wx.grid.GridCellCoords) – |
---|
MoveCursorDown
(self, expandSelection)¶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: | expandSelection (bool) – |
---|---|
Return type: | bool |
MoveCursorDownBlock
(self, expandSelection)¶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: | expandSelection (bool) – |
---|---|
Return type: | bool |
MoveCursorLeft
(self, expandSelection)¶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: | expandSelection (bool) – |
---|---|
Return type: | bool |
MoveCursorLeftBlock
(self, expandSelection)¶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: | expandSelection (bool) – |
---|---|
Return type: | bool |
MoveCursorRight
(self, expandSelection)¶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: | expandSelection (bool) – |
---|---|
Return type: | bool |
MoveCursorRightBlock
(self, expandSelection)¶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: | expandSelection (bool) – |
---|---|
Return type: | bool |
MoveCursorUp
(self, expandSelection)¶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: | expandSelection (bool) – |
---|---|
Return type: | bool |
MoveCursorUpBlock
(self, expandSelection)¶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: | expandSelection (bool) – |
---|---|
Return type: | bool |
MovePageDown
(self)¶Moves the grid cursor down by some number of rows so that the previous bottom visible row becomes the top visible row.
Return type: | bool |
---|
MovePageUp
(self)¶Moves the grid cursor up by some number of rows so that the previous top visible row becomes the bottom visible row.
Return type: | bool |
---|
ProcessTableMessage
(self, msg)¶Receive and handle a message from the table.
Parameters: | msg (wx.grid.GridTableMessage) – |
---|---|
Return type: | bool |
RefreshAttr
(self, row, col)¶Invalidates the cached attribute for the given cell.
For efficiency reasons, wx.grid.Grid may cache the recently used attributes (currently it caches only the single most recently used one, in fact) which can result in the cell appearance not being refreshed even when the attribute returned by your custom GridCellAttrProvider-derived class has changed. To force the grid to refresh the cell attribute, this function may be used. Notice that calling it will not result in actually redrawing the cell, you still need to call wx.Window.RefreshRect
to invalidate the area occupied by the cell in the window to do this. Also note that you don’t need to call this function if you store the attributes in wx.grid.Grid itself, i.e. use its SetAttr
and similar methods, it is only useful when using a separate custom attributes provider.
Parameters: |
|
---|
New in version 2.9.2.
RegisterDataType
(self, typeName, renderer, editor)¶Register a new data type.
The data types allow to naturally associate specific renderers and editors to the cells containing values of the given type. For example, the grid automatically registers a data type with the name GRID_VALUE_STRING
which uses wx.grid.GridCellStringRenderer and wx.grid.GridCellTextEditor as its renderer and editor respectively wx.grid.GridStringTable, so this renderer and editor are used by default for all grid cells.
However if a custom table returns GRID_VALUE_BOOL
from its wx.grid.GridTableBase.GetTypeName
method, then wx.grid.GridCellBoolRenderer and wx.grid.GridCellBoolEditor are used for it because the grid also registers a boolean data type with this name.
And as this mechanism is completely generic, you may register your own data types using your own custom renderers and editors. Just remember that the table must identify a cell as being of the given type for them to be used for this cell.
Parameters: |
|
---|
Render
(self, dc, pos=DefaultPosition, size=DefaultSize, topLeft=GridCellCoords(-1, -1), bottomRight=GridCellCoords(-1, -1), style=GRID_DRAW_DEFAULT)¶Draws part or all of a wx.grid.Grid on a wx.DC for printing or display.
Pagination can be accomplished by using sequential Render
calls with appropriate values in wx.grid.GridCellCoords topLeft and bottomRight.
Parameters: |
|
---|
New in version 2.9.4.
ResetColPos
(self)¶Resets the position of the columns to the default.
SaveEditControlValue
(self)¶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.
SelectAll
(self)¶Selects all cells in the grid.
SelectBlock
(self, *args, **kw)¶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.
SelectBlock (self, topRow, leftCol, bottomRow, rightCol, addToSelected=False)
Parameters: |
|
---|
SelectBlock (self, topLeft, bottomRight, addToSelected=False)
Parameters: |
|
---|
SelectCol
(self, col, addToSelected=False)¶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.
This method won’t select anything if the current selection mode is GridSelectRows.
Parameters: |
|
---|
SelectRow
(self, row, addToSelected=False)¶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.
This method won’t select anything if the current selection mode is GridSelectColumns.
Parameters: |
|
---|
SetAttr
(self, row, col, attr)¶Sets the cell attributes for the specified cell.
The grid takes ownership of the attribute pointer.
See the wx.grid.GridCellAttr class for more information about controlling cell attributes.
Parameters: |
|
---|
SetCellAlignment
(self, *args, **kw)¶Sets the horizontal and vertical alignment for grid cell text at the specified location.
Horizontal alignment should be one of ALIGN_LEFT
, ALIGN_CENTRE
or ALIGN_RIGHT
.
Vertical alignment should be one of ALIGN_TOP
, ALIGN_CENTRE
or ALIGN_BOTTOM
.
SetCellAlignment (self, row, col, horiz, vert)
Parameters: |
|
---|
SetCellAlignment (self, align, row, col)
Parameters: |
|
---|
SetCellBackgroundColour
(self, row, col, colour)¶Set the background colour for the given cell or all cells by default.
Parameters: |
|
---|
SetCellEditor
(self, row, col, editor)¶Sets the editor for the grid cell at the specified location.
The grid will take ownership of the pointer.
See wx.grid.GridCellEditor and the Grid Overview for more information about cell editors and renderers.
Parameters: |
|
---|
SetCellFont
(self, row, col, font)¶Sets the font for text in the grid cell at the specified location.
Parameters: |
|
---|
SetCellHighlightPenWidth
(self, width)¶Parameters: | width (int) – |
---|
SetCellHighlightROPenWidth
(self, width)¶Parameters: | width (int) – |
---|
SetCellOverflow
(self, row, col, allow)¶Sets the overflow permission of the cell.
Parameters: |
|
---|
SetCellRenderer
(self, row, col, renderer)¶Sets the renderer for the grid cell at the specified location.
The grid will take ownership of the pointer.
See wx.grid.GridCellRenderer and the Grid Overview for more information about cell editors and renderers.
Parameters: |
|
---|
SetCellSize
(self, row, col, num_rows, num_cols)¶Set the size of the cell.
Specifying a value of more than 1 in num_rows or num_cols will make the cell at (row, col) span the block of the specified size, covering the other cells which would be normally shown in it. Passing 1 for both arguments resets the cell to normal appearance.
Parameters: |
|
---|
See also
SetCellTextColour
(self, *args, **kw)¶SetCellTextColour (self, row, col, colour)
Sets the text colour for the given cell.
Parameters: |
|
---|
SetCellTextColour (self, val, row, col)
Sets the text colour for the given cell.
Parameters: |
|
---|
SetCellTextColour (self, colour)
Sets the text colour for all cells by default.
Parameters: | colour (wx.Colour) – |
---|
SetCellValue
(self, *args, **kw)¶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
and the Grid Overview for more information.
SetCellValue (self, row, col, s)
Parameters: |
|
---|
SetCellValue (self, coords, s)
Parameters: |
|
---|
SetColAttr
(self, col, attr)¶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 and the Grid Overview.
Parameters: |
|
---|
SetColFormatBool
(self, col)¶Sets the specified column to display boolean values.
Parameters: | col (int) – |
---|
See also
SetColFormatCustom
(self, col, typeName)¶Sets the specified column to display data in a custom format.
This method provides an alternative to defining a custom grid table which would return typeName from its GetTypeName() method for the cells in this column: while it doesn’t really change the type of the cells in this column, it does associate the renderer and editor used for the cells of the specified type with them.
See the Grid Overview for more information on working with custom data types.
Parameters: |
|
---|
SetColFormatFloat
(self, col, width=-1, precision=-1)¶Sets the specified column to display floating point values with the given width and precision.
Parameters: |
|
---|
See also
SetColFormatNumber
(self, col)¶Sets the specified column to display integer values.
Parameters: | col (int) – |
---|
See also
SetColLabelAlignment
(self, horiz, vert)¶Sets the horizontal and vertical alignment of column label text.
Horizontal alignment should be one of ALIGN_LEFT
, ALIGN_CENTRE
or ALIGN_RIGHT
. Vertical alignment should be one of ALIGN_TOP
, ALIGN_CENTRE
or ALIGN_BOTTOM
.
Parameters: |
|
---|
SetColLabelSize
(self, height)¶Sets the height of the column labels.
If height equals to GRID_AUTOSIZE
then height is calculated automatically so that no label is truncated. Note that this could be slow for a large table.
Parameters: | height (int) – |
---|
SetColLabelTextOrientation
(self, textOrientation)¶Sets the orientation of the column labels (either HORIZONTAL
or VERTICAL
).
Parameters: | textOrientation (int) – |
---|
SetColLabelValue
(self, col, value)¶Set the value for the given column label.
If you are using a custom grid table you must override wx.grid.GridTableBase.SetColLabelValue
for this to have any effect.
Parameters: |
|
---|
SetColMinimalAcceptableWidth
(self, width)¶Sets the minimal width to which the user can resize columns.
Parameters: | width (int) – |
---|
See also
SetColMinimalWidth
(self, col, width)¶Sets the minimal width for the specified column col.
It is usually best to call this method during grid creation as calling it later will not resize the column to the given minimal width even if it is currently narrower than it.
width must be greater than the minimal acceptable column width as returned by GetColMinimalAcceptableWidth
.
Parameters: |
|
---|
SetColPos
(self, colID, newPos)¶Sets the position of the specified column.
Parameters: |
|
---|
SetColSize
(self, col, width)¶Sets the width of the specified column.
Parameters: |
|
---|
SetColSizes
(self, sizeInfo)¶Restore all columns sizes.
This is usually called with wx.grid.GridSizesInfo object previously returned by GetColSizes
.
Parameters: | sizeInfo (wx.grid.GridSizesInfo) – |
---|
See also
SetColumnsOrder
(self, order)¶Sets the positions of all columns at once.
This method takes an array containing the indices of the columns in their display order, i.e. uses the same convention as wx.HeaderCtrl.SetColumnsOrder
.
Parameters: | order (list of integers) – |
---|
SetDefaultCellAlignment
(self, horiz, vert)¶Sets the default horizontal and vertical alignment for grid cell text.
Horizontal alignment should be one of ALIGN_LEFT
, ALIGN_CENTRE
or ALIGN_RIGHT
. Vertical alignment should be one of ALIGN_TOP
, ALIGN_CENTRE
or ALIGN_BOTTOM
.
Parameters: |
|
---|
SetDefaultCellBackgroundColour
(self, colour)¶Sets the default background colour for grid cells.
Parameters: | colour (wx.Colour) – |
---|
SetDefaultCellFont
(self, font)¶Sets the default font to be used for grid cell text.
Parameters: | font (wx.Font) – |
---|
SetDefaultCellOverflow
(self, allow)¶Sets the default overflow permission of the cells.
Parameters: | allow (bool) – |
---|
SetDefaultCellTextColour
(self, colour)¶Sets the current default colour for grid cell text.
Parameters: | colour (wx.Colour) – |
---|
SetDefaultColSize
(self, width, resizeExistingCols=False)¶Sets the default width for columns in the grid.
This will only affect columns subsequently added to the grid unless resizeExistingCols is True
.
If width is less than GetColMinimalAcceptableWidth
, then the minimal acceptable width is used instead of it.
Parameters: |
|
---|
SetDefaultEditor
(self, editor)¶Sets the default editor for grid cells.
The grid will take ownership of the pointer.
See wx.grid.GridCellEditor and the Grid Overview for more information about cell editors and renderers.
Parameters: | editor (wx.grid.GridCellEditor) – |
---|
SetDefaultRenderer
(self, renderer)¶Sets the default renderer for grid cells.
The grid will take ownership of the pointer.
See wx.grid.GridCellRenderer and the Grid Overview for more information about cell editors and renderers.
Parameters: | renderer (wx.grid.GridCellRenderer) – |
---|
SetDefaultRowSize
(self, height, resizeExistingRows=False)¶Sets the default height for rows in the grid.
This will only affect rows subsequently added to the grid unless resizeExistingRows is True
.
If height is less than GetRowMinimalAcceptableHeight
, then the minimal acceptable height is used instead of it.
Parameters: |
|
---|
SetGridCursor
(self, *args, **kw)¶Set the grid cursor to the specified cell.
The grid cursor indicates the current cell and can be moved by the user using the arrow keys or the mouse.
Calling this function generates a wxEVT_GRID_SELECT_CELL
event and if the event handler vetoes this event, the cursor is not moved.
This function doesn’t make the target call visible, use GoToCell
to do this.
SetGridCursor (self, row, col)
Parameters: |
|
---|
SetGridCursor (self, coords)
Parameters: | coords (wx.grid.GridCellCoords) – |
---|
SetGridLineColour
(self, colour)¶Sets the colour used to draw grid lines.
Parameters: | colour (wx.Colour) – |
---|
SetLabelBackgroundColour
(self, colour)¶Sets the background colour for row and column labels.
Parameters: | colour (wx.Colour) – |
---|
SetLabelTextColour
(self, colour)¶Sets the colour for row and column label text.
Parameters: | colour (wx.Colour) – |
---|
SetMargins
(self, extraWidth, extraHeight)¶Sets the extra margins used around the grid area.
A grid may occupy more space than needed for its data display and this function allows to set how big this extra space is
Parameters: |
|
---|
SetReadOnly
(self, row, col, isReadOnly=True)¶Makes the cell at the specified location read-only or editable.
Parameters: |
|
---|
See also
SetRowAttr
(self, row, attr)¶Sets the cell attributes for all cells in the specified row.
The grid takes ownership of the attribute pointer.
See the wx.grid.GridCellAttr class for more information about controlling cell attributes.
Parameters: |
|
---|
SetRowLabelAlignment
(self, horiz, vert)¶Sets the horizontal and vertical alignment of row label text.
Horizontal alignment should be one of ALIGN_LEFT
, ALIGN_CENTRE
or ALIGN_RIGHT
. Vertical alignment should be one of ALIGN_TOP
, ALIGN_CENTRE
or ALIGN_BOTTOM
.
Parameters: |
|
---|
SetRowLabelSize
(self, width)¶Sets the width of the row labels.
If width equals GRID_AUTOSIZE
then width is calculated automatically so that no label is truncated. Note that this could be slow for a large table.
Parameters: | width (int) – |
---|
SetRowLabelValue
(self, row, value)¶Sets 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: |
|
---|
SetRowMinimalAcceptableHeight
(self, height)¶Sets the minimal row height used by default.
See SetColMinimalAcceptableWidth
for more information.
Parameters: | height (int) – |
---|
SetRowMinimalHeight
(self, row, height)¶Sets the minimal height for the specified row.
See SetColMinimalWidth
for more information.
Parameters: |
|
---|
SetRowSize
(self, row, height)¶Sets the height of the specified row.
See SetColSize
for more information.
Parameters: |
|
---|
SetRowSizes
(self, sizeInfo)¶Restore all rows sizes.
Parameters: | sizeInfo (wx.grid.GridSizesInfo) – |
---|
See also
SetScrollLineX
(self, x)¶Sets the number of pixels per horizontal scroll increment.
The default is 15.
Parameters: | x (int) – |
---|
See also
SetScrollLineY
(self, y)¶Sets the number of pixels per vertical scroll increment.
The default is 15.
Parameters: | y (int) – |
---|
See also
SetSelectionBackground
(self, c)¶Set the colour to be used for drawing the selection background.
Parameters: | c (wx.Colour) – |
---|
SetSelectionForeground
(self, c)¶Set the colour to be used for drawing the selection foreground.
Parameters: | c (wx.Colour) – |
---|
SetSelectionMode
(self, selmode)¶Set the selection behaviour of the grid.
The existing selection is converted to conform to the new mode if possible and discarded otherwise (e.g. any individual selected cells are deselected if the new mode allows only the selection of the entire rows or columns).
Parameters: | selmode (GridSelectionModes) – |
---|
SetSortingColumn
(self, col, ascending=True)¶Set the column to display the sorting indicator in and its direction.
Parameters: |
|
---|
See also
SetTabBehaviour
(self, behaviour)¶Set the grid’s behaviour when the user presses the TAB
key.
Pressing the TAB
key moves the grid cursor right in the current row, if there is a cell at the right and, similarly, Shift-TAB moves the cursor to the left in the current row if it’s not in the first column.
What happens if the cursor can’t be moved because it it’s already at the beginning or end of the row can be configured using this function, see wx.grid.Grid.TabBehaviour documentation for the detailed description.
IF
none of the standard behaviours is appropriate, you can always handle wxEVT_GRID_TABBING
event directly to implement a custom TAB-handling logic.
Parameters: | behaviour (TabBehaviour) – |
---|
New in version 2.9.5.
_SetTable
(self, table, takeOwnership=False, selmode=GridSelectCells)¶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: |
|
---|---|
Return type: | bool |
SetTable
(self, table, takeOwnership=False, selmode=Grid.SelectCells)¶Set the Grid Table to be used by this grid.
SetUseNativeColLabels
(self, native=True)¶Call this in order to make the column labels use a native look by using wx.RendererNative.DrawHeaderButton
internally.
There is no equivalent method for drawing row columns as there is not native look for that. This option is useful when using wx.grid.Grid for displaying tables and not as a spread-sheet.
Parameters: | native (bool) – |
---|
See also
ShowCellEditControl
(self)¶Displays the in-place cell edit control for the current cell.
ShowCol
(self, col)¶Shows the previously hidden column by resizing it to non-0 size.
The column is shown again with the same width that it had before HideCol
call.
If the column is currently shown, this method doesn’t do anything.
Parameters: | col (int) – |
---|
See also
ShowRow
(self, col)¶Shows the previously hidden row.
The row is shown again with the same height that it had before HideRow
call.
If the row is currently shown, this method doesn’t do anything.
Parameters: | col (int) – |
---|
See also
UnsetSortingColumn
(self)¶Remove any currently shown sorting indicator.
This is equivalent to calling SetSortingColumn
with NOT_FOUND
first argument.
UseNativeColHeader
(self, native=True)¶Enable the use of native header window for column labels.
If this function is called with True
argument, a wx.HeaderCtrl is used instead to display the column labels instead of drawing them in wx.grid.Grid code itself. This has the advantage of making the grid look and feel perfectly the same as native applications (using SetUseNativeColLabels
the grid can be made to look more natively but it still doesn’t feel natively, notably the column resizing and dragging still works slightly differently as it is implemented in wxWidgets itself) but results in different behaviour for column and row headers, for which there is no equivalent function, and, most importantly, is unsuitable for grids with huge numbers of columns as wx.HeaderCtrl doesn’t support virtual mode. Because of this, by default the grid does not use the native header control but you should call this function to enable it if you are using the grid to display tabular data and don’t have thousands of columns in it.
Another difference between the default behaviour and the native header behaviour is that the latter provides the user with a context menu (which appears on right clicking the header) allowing to rearrange the grid columns if CanDragColMove
returns True
. If you want to prevent this from happening for some reason, you need to define a handler for wxEVT_GRID_LABEL_RIGHT_CLICK
event which simply does nothing (in particular doesn’t skip the event) as this will prevent the default right click handling from working.
Also note that currently wxEVT_GRID_LABEL_RIGHT_DCLICK
event is not generated for the column labels if the native columns header is used (but this limitation could possibly be lifted in the future).
Parameters: | native (bool) – |
---|
XToCol
(self, x, clipToMinMax=False)¶Returns the column at the given pixel position.
Parameters: |
|
---|---|
Return type: | int |
Returns: | The column index or |
XToEdgeOfCol
(self, x)¶Returns the column whose right hand edge is close to the given logical x position.
If no column edge is near to this position NOT_FOUND
is returned.
Parameters: | x (int) – |
---|---|
Return type: | int |
XYToCell
(self, *args, **kw)¶Translates logical pixel coordinates to the grid cell coordinates.
Notice that this function expects logical coordinates on input so if you use this function in a mouse event handler you need to translate the mouse position, which is expressed in device coordinates, to logical ones.
XYToCell (self, x, y)
Parameters: |
|
---|---|
Return type: |
XYToCell (self, pos)
Parameters: | pos (wx.Point) – |
---|---|
Return type: | wx.grid.GridCellCoords |
YToEdgeOfRow
(self, y)¶Returns the row whose bottom edge is close to the given logical y position.
If no row edge is near to this position NOT_FOUND
is returned.
Parameters: | y (int) – |
---|---|
Return type: | int |
YToRow
(self, y, clipToMinMax=False)¶Returns the grid row that corresponds to the logical y coordinate.
Returns NOT_FOUND
if there is no row at the y position.
Parameters: |
|
---|---|
Return type: | int |
BatchCount
¶See GetBatchCount
CellHighlightColour
¶CellHighlightPenWidth
¶CellHighlightROPenWidth
¶See GetCellHighlightROPenWidth
and SetCellHighlightROPenWidth
ColLabelSize
¶See GetColLabelSize
and SetColLabelSize
ColLabelTextOrientation
¶See GetColLabelTextOrientation
and SetColLabelTextOrientation
ColMinimalAcceptableWidth
¶See GetColMinimalAcceptableWidth
and SetColMinimalAcceptableWidth
ColSizes
¶See GetColSizes
and SetColSizes
DefaultCellBackgroundColour
¶See GetDefaultCellBackgroundColour
and SetDefaultCellBackgroundColour
DefaultCellFont
¶See GetDefaultCellFont
and SetDefaultCellFont
DefaultCellOverflow
¶DefaultCellTextColour
¶DefaultColLabelSize
¶DefaultColSize
¶See GetDefaultColSize
and SetDefaultColSize
DefaultEditor
¶See GetDefaultEditor
and SetDefaultEditor
DefaultGridLinePen
¶DefaultRenderer
¶See GetDefaultRenderer
and SetDefaultRenderer
DefaultRowLabelSize
¶DefaultRowSize
¶See GetDefaultRowSize
and SetDefaultRowSize
GridColHeader
¶See GetGridColHeader
GridColLabelWindow
¶GridCornerLabelWindow
¶GridCursorCol
¶See GetGridCursorCol
GridCursorRow
¶See GetGridCursorRow
GridLineColour
¶See GetGridLineColour
and SetGridLineColour
GridRowLabelWindow
¶GridWindow
¶See GetGridWindow
LabelBackgroundColour
¶LabelFont
¶See GetLabelFont
and SetLabelFont
LabelTextColour
¶See GetLabelTextColour
and SetLabelTextColour
NumberCols
¶See GetNumberCols
NumberRows
¶See GetNumberRows
RowLabelSize
¶See GetRowLabelSize
and SetRowLabelSize
RowMinimalAcceptableHeight
¶See GetRowMinimalAcceptableHeight
and SetRowMinimalAcceptableHeight
RowSizes
¶See GetRowSizes
and SetRowSizes
ScrollLineX
¶See GetScrollLineX
and SetScrollLineX
ScrollLineY
¶See GetScrollLineY
and SetScrollLineY
SelectedCells
¶See GetSelectedCells
SelectedCols
¶See GetSelectedCols
SelectedRows
¶See GetSelectedRows
SelectionBackground
¶SelectionBlockBottomRight
¶SelectionBlockTopLeft
¶SelectionForeground
¶SelectionMode
¶See GetSelectionMode
and SetSelectionMode
SortingColumn
¶See GetSortingColumn
and SetSortingColumn