0

I am trying to intercept the text being typed into the Cell Editor of a wx.grid object by creating a custom cell editor and setting it as the default cell editor of my grid.

As a test I did the following:

class CellEditor(wx.grid.GridCellTextEditor):
    def __init__(self):
        wx.MessageBox("Init")
        super(CellEditor, self).__init__()

    def BeginEdit(self, *args, **kwargs):
        wx.MessageBox("Begin Edit")
        super(CellEditor, self).BeginEdit(*args, **kwargs)

While the "Init" message box shows up, the "begin edit" message box never appears. Even if I explicitly call the BeginEdit() method from the debugger, the message box is not displayed. This makes me think somehow the BeginEdit method is being re-written over by the original method during initialization. Come someone help me understand what's happening?

jsexauer
  • 681
  • 2
  • 12
  • 22

1 Answers1

0

I do not completely understand the magic behind the custom cell editors, but this example may be a good starting point. It seems that you have to override more methods in order to make it work.

Also I would be careful with overriding methods, your method signature BeginEdit(self, *args, **kwargs) does not match the overriden one which is BeginEdit(self, row, col, grid). I did some quick tests to see if you can override methods like this and it seems so, but it is confusing and may lead to mistakes.

Fenikso
  • 9,251
  • 5
  • 44
  • 72