wx.grid.GridCellEditor¶
This class is responsible for providing and manipulating the in-place edit controls for the grid.
Instances of wx.grid.GridCellEditor (actually, instances of derived classes since it is an abstract class) can be associated with the cell attributes for individual cells, rows, columns, or even for the entire grid.
Normally wx.grid.GridCellEditor shows some UI control allowing the user to edit the cell, but starting with wxWidgets 3.1.4 it’s also possible to define “activatable” cell editors, that change the value of the cell directly when it’s activated (typically by pressing Space key or clicking on it), see TryActivate
method. Note that when implementing an editor which is always activatable, i.e. never shows any in-place editor, it is more convenient to derive its class from wx.grid.GridCellActivatableEditor than from wx.grid.GridCellEditor itself.
See also
wx.grid.GridCellAutoWrapStringEditor, wx.grid.GridCellBoolEditor, wx.grid.GridCellChoiceEditor, wx.grid.GridCellEnumEditor, wx.grid.GridCellFloatEditor, wx.grid.GridCellNumberEditor, wx.grid.GridCellTextEditor, wx.grid.GridCellDateEditor
Class Hierarchy¶
Known Subclasses¶
wx.grid.GridCellActivatableEditor, wx.grid.GridCellBoolEditor, wx.grid.GridCellChoiceEditor, wx.grid.GridCellDateEditor, wx.grid.GridCellTextEditor
Methods Summary¶
Default constructor. |
|
Effectively save the changes in the grid. |
|
Fetch the value from the table and prepare the edit control to begin editing. |
|
Create a new object which is the copy of this one. |
|
Creates the actual edit control. |
|
Final cleanup. |
|
Function which must be overridden for “activatable” editors. |
|
End editing the cell. |
|
Get the wx.Control used by this editor. |
|
Returns the value currently in the editor control. |
|
Get the edit window used by this editor. |
|
Some types of controls on some platforms may need some help with the Return key. |
|
Return |
|
Returns |
|
Draws the part of the cell not occupied by the control: the base class version just fills it with background colour from the attribute. |
|
Reset the value in the control back to its starting value. |
|
Set the wx.Control that will be used by this cell editor for editing the value. |
|
Size and position the edit control. |
|
Set the wx.Window that will be used by this cell editor for editing the value. |
|
Show or hide the edit control, use the specified attributes to set colours/fonts for it. |
|
If the editor is enabled by clicking on the cell, this method will be called. |
|
If the editor is enabled by pressing keys on the grid, this will be called to let the editor do something about that first key if desired. |
|
Function allowing to create an “activatable” editor. |
|
|
The destructor is private because only |
Properties Summary¶
See |
|
See |
|
Class API¶
- class wx.grid.GridCellEditor(SharedClientDataContainer, RefCounter)¶
Possible constructors:
GridCellEditor() -> None
This class is responsible for providing and manipulating the in-place edit controls for the grid.
Methods¶
- __init__(self)¶
Default constructor.
- Return type:
None
- ApplyEdit(self, row, col, grid)¶
Effectively save the changes in the grid.
This function should save the value of the control in the grid. It is called only after
EndEdit
returnsTrue
.- Parameters:
row (int)
col (int)
grid (wx.grid.Grid)
- Return type:
None
- BeginEdit(self, row, col, grid)¶
Fetch the value from the table and prepare the edit control to begin editing.
This function should save the original value of the grid cell at the given row and col and show the control allowing the user to change it.
- Parameters:
row (int)
col (int)
grid (wx.grid.Grid)
- Return type:
None
See also
- Clone(self)¶
Create a new object which is the copy of this one.
- Return type:
- Create(self, parent, id, evtHandler)¶
Creates the actual edit control.
- Parameters:
parent (wx.Window)
id (wx.WindowID)
evtHandler (wx.EvtHandler)
- Return type:
None
- Destroy(self)¶
Final cleanup.
- Return type:
None
- DoActivate(self, row, col, grid)¶
Function which must be overridden for “activatable” editors.
If
TryActivate
is overridden to return “change” action, this function will be called to actually apply this change. Note that it is not passed the value to apply, as it is assumed that the editor class stores this value as a member variable anyhow.- Parameters:
row (int)
col (int)
grid (wx.grid.Grid)
- Return type:
None
Added in version 4.1/wxWidgets-3.1.4.
- EndEdit(self, row, col, grid, oldval)¶
End editing the cell.
This function must check if the current value of the editing cell is valid and different from the original value in its string form. If not then simply return None. If it has changed then this method should save the new value so that ApplyEdit can apply it later and the string representation of the new value should be returned.
Notice that this method shoiuld not modify the grid as the change could still be vetoed.
- Return type:
Any
- GetControl(self)¶
Get the wx.Control used by this editor.
This function is preserved for compatibility, but
GetWindow
should be preferred in the new code as the associated window doesn’t need to be of a Control-derived class.Note that if
SetWindow
had been called with an object not deriving from wx.Control, this method will returnNone
.- Return type:
- GetValue(self)¶
Returns the value currently in the editor control.
- Return type:
str
- GetWindow(self)¶
Get the edit window used by this editor.
- Return type:
Added in version 4.1/wxWidgets-3.1.3.
- HandleReturn(self, event)¶
Some types of controls on some platforms may need some help with the Return key.
- Parameters:
event (wx.KeyEvent)
- Return type:
None
- IsAcceptedKey(self, event)¶
Return
True
to allow the given key to start editing: the base class version only checks that the event has no modifiers.If the key is
F2
(special), editing will always start and this method will not be called at all (butStartingKey
will)- Parameters:
event (wx.KeyEvent)
- Return type:
bool
- IsCreated(self)¶
Returns
True
if the edit control has been created.- Return type:
bool
- PaintBackground(self, dc, rectCell, attr)¶
Draws the part of the cell not occupied by the control: the base class version just fills it with background colour from the attribute.
- Parameters:
dc (wx.DC)
rectCell (wx.Rect)
attr (wx.grid.GridCellAttr)
- Return type:
None
- Reset(self)¶
Reset the value in the control back to its starting value.
- Return type:
None
- SetControl(self, control)¶
Set the wx.Control that will be used by this cell editor for editing the value.
This function is preserved for compatibility, but
SetWindow
should be preferred in the new code, seeGetControl
.- Parameters:
control (wx.Control)
- Return type:
None
- SetSize(self, rect)¶
Size and position the edit control.
- Parameters:
rect (wx.Rect)
- Return type:
None
- SetWindow(self, window)¶
Set the wx.Window that will be used by this cell editor for editing the value.
- Parameters:
window (wx.Window)
- Return type:
None
Added in version 4.1/wxWidgets-3.1.3.
- Show(self, show, attr=None)¶
Show or hide the edit control, use the specified attributes to set colours/fonts for it.
- Parameters:
show (bool)
attr (wx.grid.GridCellAttr)
- Return type:
None
- StartingClick(self)¶
If the editor is enabled by clicking on the cell, this method will be called.
- Return type:
None
- StartingKey(self, event)¶
If the editor is enabled by pressing keys on the grid, this will be called to let the editor do something about that first key if desired.
- Parameters:
event (wx.KeyEvent)
- Return type:
None
- TryActivate(self, row, col, grid, actSource)¶
Function allowing to create an “activatable” editor.
As explained in this class description, activatable editors don’t show any edit control but change the cell value directly, when it is activated (by any way described by wx.grid.GridActivationSource).
To create such editor, this method must be overridden to return
wx.grid.GridActivationResult.DoChange
passing it the new value of the cell. If the change is not vetoed by wxEVT_GRID_CELL_CHANGING handler,DoActivate
will be called to actually change the value, so it must be overridden as well ifTryActivate
is overridden.By default,
wx.grid.GridActivationResult.DoEdit
is returned, meaning that this is a normal editor, using an edit control for changing the cell value.- Parameters:
row (int)
col (int)
grid (wx.grid.Grid)
actSource (wx.grid.GridActivationSource)
- Return type:
Added in version 4.1/wxWidgets-3.1.4.
- ~wxGridCellEditor(self)
The destructor is private because only
DecRef
can delete us.- Return type:
None
Properties¶
- Control¶
See
GetControl
andSetControl