Base class for custom wx.propgrid.PropertyGrid editors.
Note
Names of built-in property editors are: TextCtrl, Choice, ComboBox, CheckBox, TextCtrlAndButton, and ChoiceAndButton. Additional editors include SpinCtrl and DatePickerCtrl, but using them requires calling wx.propgrid.PropertyGrid.RegisterAdditionalEditors
prior use.
Pointer to built-in editor is available as PGEditor_EditorName (e.g. PGEditor_TextCtrl).
Before you start using new editor you just created, you need to register it using static function wx.propgrid.PropertyGrid.RegisterEditorClass
, with code like this:
editorPointer = wx.propgrid.PropertyGrid.RegisterEditorClass(MyEditorClass(), “MyEditor”)
After that, wx.propgrid.PropertyGrid will take ownership of the given object, but you should still store editorPointer somewhere, so you can pass it to wx.propgrid.PGProperty.SetEditor
, or return it from PGEditor.DoGetEditorClass().
wx.propgrid.PGCheckBoxEditor, wx.propgrid.PGChoiceEditor, wx.propgrid.PGTextCtrlEditor
Constructor. |
|
Returns |
|
Instantiates editor controls. |
|
Deletes item from existing control. |
|
Draws value for given property. |
|
Returns pointer to the name of the editor. |
|
Returns value from control, via parameter variant. |
|
Inserts item to existing control. |
|
Handles events. |
|
Extra processing when control gains focus. |
|
Called by property grid to set new appearance for the control. |
|
Sets control’s value specifically from int (applies to choice etc.). |
|
Sets control’s value specifically from string. |
|
Sets value in control to unspecified. |
|
Loads value from property to the control. |
See |
|
wx.propgrid.
PGEditor
(Object)¶Possible constructors:
PGEditor()
Base class for custom PropertyGrid editors.
__init__
(self)¶Constructor.
CanContainCustomImage
(self)¶Returns True
if control itself can contain the custom image.
Default implementation returns False
.
bool
CreateControls
(self, propgrid, property, pos, size)¶Instantiates editor controls.
propgrid (wx.propgrid.PropertyGrid) – wx.propgrid.PropertyGrid to which the property belongs (use as parent for control).
property (wx.propgrid.PGProperty) – Property for which this method is called.
pos (wx.Point) – Position, inside wx.propgrid.PropertyGrid, to create control(s) to.
size (wx.Size) – Initial size for control(s).
Note
It is not necessary to call wx.EvtHandler.Bind
for interesting editor events. All events from controls are automatically forwarded to wx.propgrid.PGEditor.OnEvent
and wx.propgrid.PGProperty.OnEvent
.
DeleteItem
(self, ctrl, index)¶Deletes item from existing control.
Default implementation does nothing.
ctrl (wx.Window) –
index (int) –
DrawValue
(self, dc, rect, property, text)¶Draws value for given property.
dc (wx.DC) –
rect (wx.Rect) –
property (wx.propgrid.PGProperty) –
text (string) –
GetName
(self)¶Returns pointer to the name of the editor.
For example, PGEditor_TextCtrl has name “TextCtrl”. If you don’t need to access your custom editor by string name, then you do not need to implement this function.
string
GetValueFromControl
(self, property, ctrl)¶Returns value from control, via parameter variant.
Usually ends up calling property’s StringToValue() or IntToValue(). Returns True
if value was different.
property (wx.propgrid.PGProperty) –
ctrl (wx.Window) –
tuple
( bool, variant )
InsertItem
(self, ctrl, label, index)¶Inserts item to existing control.
Index -1 means end of list. Default implementation does nothing. Returns index of item added.
ctrl (wx.Window) –
label (string) –
index (int) –
int
OnEvent
(self, propgrid, property, wnd_primary, event)¶Handles events.
Returns True
if value in control was modified (see wx.propgrid.PGProperty.OnEvent
for more information).
propgrid (wx.propgrid.PropertyGrid) –
property (wx.propgrid.PGProperty) –
wnd_primary (wx.Window) –
event (wx.Event) –
bool
Note
wx.propgrid.PropertyGrid will automatically unfocus the editor when wxEVT_TEXT_ENTER
is received and when it results in property value being modified. This happens regardless of editor type (i.e. behaviour is same for any wx.TextCtrl and wx.ComboBox based editor).
OnFocus
(self, property, wnd)¶Extra processing when control gains focus.
For example, wx.TextCtrl based controls should select all text.
property (wx.propgrid.PGProperty) –
wnd (wx.Window) –
SetControlAppearance
(self, pg, property, ctrl, appearance, oldAppearance, unspecified)¶Called by property grid to set new appearance for the control.
Default implementation sets foreground colour, background colour, font, plus text for wx.TextCtrl and wx.ComboCtrl.
pg (wx.propgrid.PropertyGrid) – Property grid to which the edited property belongs.
property (wx.propgrid.PGProperty) – Edited property to which the editor control belongs.
ctrl (wx.Window) – Editor control.
appearance (wx.propgrid.PGCell) – New appearance to be applied.
oldAppearance (wx.propgrid.PGCell) – Previously applied appearance. Used to detect which control attributes need to be changed (e.g. so we only change background colour if really needed).
unspecified (bool) – If True
tells this function that the new appearance represents an unspecified property value.
SetControlIntValue
(self, property, ctrl, value)¶Sets control’s value specifically from int (applies to choice etc.).
property (wx.propgrid.PGProperty) –
ctrl (wx.Window) –
value (int) –
SetControlStringValue
(self, property, ctrl, txt)¶Sets control’s value specifically from string.
property (wx.propgrid.PGProperty) –
ctrl (wx.Window) –
txt (string) –
SetValueToUnspecified
(self, property, ctrl)¶Sets value in control to unspecified.
property (wx.propgrid.PGProperty) –
ctrl (wx.Window) –
UpdateControl
(self, property, ctrl)¶Loads value from property to the control.
property (wx.propgrid.PGProperty) –
ctrl (wx.Window) –