Search code examples
pythonwxpythonwxwidgets

How to capture events for each key press in wxPropertyGrid


In wxPython I'm trying to update an existing UI to use wxPropertyGrid instead of an array of individual UI elements. Currently the underlying object model is updated and validation is applied after each key press and I want to do the same with the PropertyGrid.

The problem I'm having is that there doesn't seem to exist a wxPropertyGridEvent which triggers on every key stroke like wx.EVT_TEXT, the closest is EVT_PG_CHANGED but that only triggers when you change between rows in the grid. I can get round this to an extent by binding wx.EVT_TEXT to the PropertyGrid but then I'm unable to use event.GetProperty() in order to access the property data as the event is not a PropertyGridEvent.

So the question is have I missed something and is there an existing event which I can use? Failing that any ideas on how I get around this problem?


Solution

  • Turns out you can capture EVT_CHAR events by binding directly to the text ctrl. As the text ctrl is only created when the property is selected however you can't do this when setting up the grid, rather you have to bind it following a EVT_PG_SELECTED event.