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
wx.grid.GridCellActivatableEditor, wx.grid.GridCellBoolEditor, wx.grid.GridCellChoiceEditor, wx.grid.GridCellDateEditor, wx.grid.GridCellTextEditor
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 |
See |
|
See |
|
wx.grid.
GridCellEditor
(SharedClientDataContainer, RefCounter)¶Possible constructors:
GridCellEditor()
This class is responsible for providing and manipulating the in-place edit controls for the grid.
__init__
(self)¶Default constructor.
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
returns True
.
row (int) –
col (int) –
grid (wx.grid.Grid) –
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.
row (int) –
col (int) –
grid (wx.grid.Grid) –
See also
Clone
(self)¶Create a new object which is the copy of this one.
Create
(self, parent, id, evtHandler)¶Creates the actual edit control.
parent (wx.Window) –
id (wx.WindowID) –
evtHandler (wx.EvtHandler) –
Destroy
(self)¶Final cleanup.
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.
row (int) –
col (int) –
grid (wx.grid.Grid) –
New 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.
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 return None
.
GetValue
(self)¶Returns the value currently in the editor control.
string
GetWindow
(self)¶Get the edit window used by this editor.
New 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.
event (wx.KeyEvent) –
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 (but StartingKey
will)
event (wx.KeyEvent) –
bool
IsCreated
(self)¶Returns True
if the edit control has been created.
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.
dc (wx.DC) –
rectCell (wx.Rect) –
attr (wx.grid.GridCellAttr) –
Reset
(self)¶Reset the value in the control back to its starting value.
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, see GetControl
.
control (wx.Control) –
SetWindow
(self, window)¶Set the wx.Window that will be used by this cell editor for editing the value.
window (wx.Window) –
New 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.
show (bool) –
attr (wx.grid.GridCellAttr) –
StartingClick
(self)¶If the editor is enabled by clicking on the cell, this method will be called.
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.
event (wx.KeyEvent) –
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 if TryActivate
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.
row (int) –
col (int) –
grid (wx.grid.Grid) –
actSource (wx.grid.GridActivationSource) –
New in version 4.1/wxWidgets-3.1.4.
~wxGridCellEditor(self)
The destructor is private because only DecRef
can delete us.
Control
¶See GetControl
and SetControl