Resizing Grid Control to be size of Parent

Chris Green wrote:

My Goal is to create a property editing widget that essentially gives
a simple editor for a dict. I'd like this to be sized the same as the
parent window so that no horizontal scrollbars are required and there
aren't odd focus shifting problems.

Right now, I've got a custom table mimicing the GridCustTable.py
example and a caller. The problem is that I don't know how to keep
the cells from displaying the horizontal scrollbar when the width gets
too much.

    width = width - wx.SystemSettings_GetMetric(wx.SYS_VSCROLL_X) \
                  - (2*num_cols)

is the best I could come up with and 4 is really 2 * num_cols. Is
there a better way to do this? Would a manually created list of text
fields be better suited to this?

class GridControl(wx.grid.Grid):
    """ This control displays and can modify active objects """
    def __init__(self, parent):
        wx.grid.Grid.__init__(self, parent, -1)
        self._parent = parent
        self._table = PropertyControlTable()
        self.SetTable(self._table)
        self.SetRowLabelSize(0)
        self.SetMargins(0,0)
        self.ClearGrid()
        self.resize()
        wx.EVT_SIZE(self, self._onSize)

    def resize(self):
        """Set the grid size"""

        (width,height) = self._parent.GetSize()

Using GetClientSize might be better here. Or even self.GetClientSize() since the grid has already been resized when this method is called.

···

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