Predefined editors

All wxPython editors are subclasses of the class wx.grid.GridCellEditor. Table 14.5 describes the standard editors.

In the next section, we'll show you how to create a custom cell editor.

Table 14.5 Cell editors in wxPython

Editor

Description

wx.grid.GridCellAutoWrapStringEditor

Uses a multi-line text control for editing the data value

wx.grid.GridCellBooleanEditor

An editor for Boolean cell data, consisting of a checkbox that the user can check or uncheck. It's visually slightly different from the checkbox used by the Boolean renderer. You do not have to have a Boolean renderer to use a Boolean editor—you could have the data display as 1 or 0 or on/off or something like that.

wx.grid.GridCellChoiceEditor

An editor for a specific list of options. When invoked, the user sees a pull-down list of the choices similar to a combo block. The constructor takes the parameters (choices, allowOthers=False). The choices parameter is the list of strings. If allowOthers is True, then the user can also type an arbitrary string in addition to selecting from the pull-down list.

wx.grid.GridCellEnumEditor

Derives from wx.grid.GridCellChoiceEditor and manages equating the numeric data value to the string presented to the user.

wx.grid.GridCellFloatEditor

An editor for entering floating point numbers with a specific precision. The constructor takes the parameters (width=-1, precision=-1), where the width is the minimum number of digits to show, and the precision is the maximum number of digits displayed after the decimal point. Numbers entered using this editor are converted to the appropriate width and precision.

wx.grid.GridCellNumberEditor

An editor for entering integer numbers. The constructor takes the parameter (min=-1, max=-1). If min and max are set, the editor does range checking and vetoes attempts to enter a number out of the range. If the editor is range checking, it also uses a spinner control on the right of the cell to allow the user to change the values via the mouse.

wx.grid.GridCellTextEditor

The default editor for entering string data.

Was this article helpful?

+1 0

Post a comment