[wxPython] Help with tabbing from GridEditor wxChoice controls

Help with tabbing from GridEditor wxChoice controls
wxPython 2.3.1 for Python 2.1

Win2k

ActivePython 2.1.1

I’ve created a custom GridEditor that is based off a wxChoice control. Everything works well except for maintaining the standard grid tabbing functionality when the grid is parented by a wxPanel and has other wxControls as siblings (parented by the same wxPanel). What happens is when tab is pressed while the choice grideditor is enabled, focus moves to the sibling controls, rather than closing the editor and moving on to the next column in the grid. I’ve tried all the wxWANTS_CHARS styles and EVT_KEY_* event hooks etc. I can find in the docs, without much luck.

To create a working example, modify the GridCustTable.py script from the wxPython demo as follows…

  1. Comment out all code that is the class TestFrame

  2. Insert the following code in its place:

class TestFrame(wxFrame):

def __init__(self, parent, log):

    wxFrame.__init__(self, parent, -1, "Custom Table, data driven Grid  Demo", size=(640,480))

    s_sizer = wxBoxSizer(wxHORIZONTAL)

    self.SetSizer(s_sizer)

    self.SetAutoLayout(true)

    sizer = wxBoxSizer(wxVERTICAL)

    p1 = wxPanel(self, -1, size = (640,480))

   

    grid = CustTableGrid(p1, log)

    text = wxTextCtrl(p1, -1)

    text2 = wxTextCtrl(p1, -1)

    sizer.Add(grid, 1, wxEXPAND)

    sizer.Add(text, 0, wxEXPAND)

    sizer.Add(text2, 0, wxEXPAND)

    p1.SetSizer(sizer)

    p1.SetAutoLayout(true)

    s_sizer.Add(p1, 1, wxEXPAND)

To demonstrate the behaviour, run the GridCustTable.py script. Focus starts out on the first cell of the Grid. Tab to the Severity column and activate the editor. Press the ‘tab’ key, and focus moves to the upper wxTextCtrl, rather than closing the editor and moving to the next column as expected. Interestingly, continuing to press tab will eventually move focus back to the grid editor, and one more press will close the editor and move to the next column!

Thanks for any help you can provide,

David.

I've created a custom GridEditor that is based off a wxChoice control.
Everything works well except for maintaining the standard grid tabbing
functionality when the grid is parented by a wxPanel and has other
wxControls as siblings (parented by the same wxPanel). What happens is

when

tab is pressed while the choice grideditor is enabled, focus moves to the
sibling controls, rather than closing the editor and moving on to the next
column in the grid. I've tried all the wxWANTS_CHARS styles and EVT_KEY_*
event hooks etc. I can find in the docs, without much luck.

That's part of the nature of wxPanels, to implement tab-traversal. I'm not
sure if there is a fix or workaround possible, but please enter this as a
bug report.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!