custom gridcelleditor

hi,

i’m trying to write a GridCellDateEditor using DatePickerCtrl.

if i changed the value in DatePickerCtrl and press Return, nothing happens.

if i select another cell then EndEdit() is called, but though its return value is non-None ApplyEdit() is not called.

do i have to bind EVT_CHAR and handle Return myself

is the example from RobinD42 (4 years ago) too old ? EndEdit() with 5 args (4 expected)

and if, is there a newer one ?

there is a tutorial at pywiki, but it doesn’t mention ApplyEdit at all and the author is not sure, whether grid-update is to place in EndEdit() ?

···

GridCellChoiceEditor takes a list as choices. works as expected.

GridCellEnumEditor requires a string as choices. how this is to use ? i already tried comma / space separated list.

thanks in advance

andreas

agraeper@googlemail.com wrote:

hi,
i'm trying to write a GridCellDateEditor using DatePickerCtrl.
if i changed the value in DatePickerCtrl and press Return, nothing happens.
if i select another cell then EndEdit() is called, but though its return
value is non-None ApplyEdit() is not called.

do i have to bind EVT_CHAR and handle Return myself

is the example from RobinD42 (4 years ago) too old ? EndEdit() with 5
args (4 expected)
and if, is there a newer one ?

there is a tutorial at pywiki, but it doesn't mention ApplyEdit at all
and the author is not sure, whether grid-update is to place in EndEdit() ?

--
GridCellChoiceEditor takes a list as choices. works as expected.
GridCellEnumEditor requires a string as choices. how this is to use ? i
already tried comma / space separated list.

Which version of wxPython are you using? Which example are you referring to? Have you tried the GridCustEditor example in the demo? (Access via the "Grid" item in the tree, then choose the 3rd button up from the bottom.)

···

--
Robin Dunn
Software Craftsman

hi,

version is 2.8.10.1.

in demo (for this version) i found that ApplyEdit is not used. and as expected new values are written to grid / table in EndEdit

but as in most cases are examples rather simple and does not explain the situation in full depths

what is method HandleReturn() for and how it is used ?

now i bind EVT_KEY (handling Return only) to the control (DatePicker) in Create()

do i have to call EndEdit(self,row,col,grid) directly ?

therefore i have to save row,col,grid in BeginEdit() .

EndEdit() has a new argument forceEnd=False

and if it is called from OnKey() keycode==Return with forceEnd=True i want to force EndEdit() to return True, no matter whether new_value != old_value or similiar.

but the Editor does not disappear. instead the methods Show() SetSize() Show() BeginEdit() are called.

what is to do ?

what is DateTimeRenderer for ? it accepts all cell-values.

if it is handling wx.DateTime objects how can i get such object instead of getting strings, how can i set objects instead of strings ?

thanks in advance

andreas

···

Am Dienstag, 9. April 2013 23:08:48 UTC+2 schrieb Robin Dunn:

agra...@googlemail.com wrote:

hi,

i’m trying to write a GridCellDateEditor using DatePickerCtrl.

if i changed the value in DatePickerCtrl and press Return, nothing happens.

if i select another cell then EndEdit() is called, but though its return

value is non-None ApplyEdit() is not called.

do i have to bind EVT_CHAR and handle Return myself

is the example from RobinD42 (4 years ago) too old ? EndEdit() with 5

args (4 expected)

and if, is there a newer one ?

there is a tutorial at pywiki, but it doesn’t mention ApplyEdit at all

and the author is not sure, whether grid-update is to place in EndEdit() ?

GridCellChoiceEditor takes a list as choices. works as expected.

GridCellEnumEditor requires a string as choices. how this is to use ? i

already tried comma / space separated list.

Which version of wxPython are you using? Which example are you
referring to? Have you tried the GridCustEditor example in the demo?
(Access via the “Grid” item in the tree, then choose the 3rd button up
from the bottom.)


Robin Dunn

Software Craftsman

http://wxPython.org

agraeper@googlemail.com wrote:

hi,
version is 2.8.10.1.

That's very old, even for the 2.8 series.

in demo (for this version) i found that ApplyEdit is not used. and as
expected new values are written to grid / table in EndEdit
but as in most cases are examples rather simple and does not explain the
situation in full depths

Most people start with the cell editor in the GridCustEditor sample in the demo and adapt it to their needs, one step at a time until it does what they need it to do. That way if there is something you do not understand now it will most likely not be something you need to worry about right away because it came from a working sample.

what is method HandleReturn() for and how it is used ?

It is a method in the base class and it will be called when the default key event handlers are processing the Return key, in case the editor class wants to do some extra processing. The default implementation doesn't do anything except Skip() the key event.

now i bind EVT_KEY (handling Return only) to the control (DatePicker) in
Create()

If you follow the example and do PushEventHandler(evtHandler) in Create then it should already be handling the key events in the control in a grid standard way, perhaps delegating them to the grid for processing.

do i have to call EndEdit(self,row,col,grid) directly ?
therefore i have to save row,col,grid in BeginEdit() .

No, the grid code should be calling it.

EndEdit() has a new argument forceEnd=False
and if it is called from OnKey() keycode==Return with forceEnd=True i
want to force EndEdit() to return True, no matter whether new_value !=
old_value or similiar.
but the Editor does not disappear. instead the methods Show() SetSize()
Show() BeginEdit() are called.
what is to do ?

You'll probably be better off just calling the grid's DisableCellEditControl() and let it take care of it.

what is DateTimeRenderer for ? it accepts all cell-values.
if it is handling wx.DateTime objects how can i get such object instead
of getting strings, how can i set objects instead of strings ?

Renderers are what are used to draw the contents of the cell when the cell editor is not active. It uses wxDateTime internally, and if I remember correctly the renderer can be created with date format strings that specify how to parse the cell's string value into a datetime object, and also the format used for display.

···

--
Robin Dunn
Software Craftsman

hi and thanks for your long answer.

i did copy your example and i did PushEventHandler(evhandler) in Create and I did overload HandleReturn(o,e) … e.Skip() to see if it is called at all (no !).

When the editor is created (DatePicker) and i do not open the month-view and i do not change anything in the little textfield than a return calls EndEdit()

the editor disappears and the cursor moves down.

but as soon as i open the month view or change inside the textfield the return is obviously not given to the grid, focus is on the textfield.

i could imagine that the key-handler of the datepicker / textfield does not skip unhandled keys correct ? maybe, this problem has gone with newer versions.

andreas

···

Am Mittwoch, 10. April 2013 18:36:10 UTC+2 schrieb Robin Dunn:

agra...@googlemail.com wrote:

hi,

version is 2.8.10.1.

That’s very old, even for the 2.8 series.

in demo (for this version) i found that ApplyEdit is not used. and as

expected new values are written to grid / table in EndEdit

but as in most cases are examples rather simple and does not explain the

situation in full depths

Most people start with the cell editor in the GridCustEditor sample in
the demo and adapt it to their needs, one step at a time until it does
what they need it to do. That way if there is something you do not
understand now it will most likely not be something you need to worry
about right away because it came from a working sample.

what is method HandleReturn() for and how it is used ?

It is a method in the base class and it will be called when the default
key event handlers are processing the Return key, in case the editor
class wants to do some extra processing. The default implementation
doesn’t do anything except Skip() the key event.

now i bind EVT_KEY (handling Return only) to the control (DatePicker) in

Create()

If you follow the example and do PushEventHandler(evtHandler) in Create
then it should already be handling the key events in the control in a
grid standard way, perhaps delegating them to the grid for processing.

do i have to call EndEdit(self,row,col,grid) directly ?

therefore i have to save row,col,grid in BeginEdit() .

No, the grid code should be calling it.

EndEdit() has a new argument forceEnd=False

and if it is called from OnKey() keycode==Return with forceEnd=True i

want to force EndEdit() to return True, no matter whether new_value !=

old_value or similiar.

but the Editor does not disappear. instead the methods Show() SetSize()

Show() BeginEdit() are called.

what is to do ?

You’ll probably be better off just calling the grid’s
DisableCellEditControl() and let it take care of it.

what is DateTimeRenderer for ? it accepts all cell-values.

if it is handling wx.DateTime objects how can i get such object instead

of getting strings, how can i set objects instead of strings ?

Renderers are what are used to draw the contents of the cell when the
cell editor is not active. It uses wxDateTime internally, and if I
remember correctly the renderer can be created with date format strings
that specify how to parse the cell’s string value into a datetime
object, and also the format used for display.


Robin Dunn

Software Craftsman

http://wxPython.org