[wxPython] wxGrid resize problems

I am attempting to create a wxGrid that automatically sizes the
rows/cols evenly on resize.

        EVT_SIZE(self, self.OnGridSize)

    def OnGridSize(self, evt):
        self.SetSize(evt.GetSize())
        self.SetMargins(0,0)
        colsize = (evt.GetSize().GetWidth() - self.GetRowLabelSize()) / self.cols
        rowsize = (evt.GetSize().GetHeight() - self.GetColLabelSize()) / self.rows
        self.BeginBatch()
        for c in range(self.cols):
            self.SetColSize(c, colsize)
        for r in range(self.rows):
            self.SetRowSize(r, rowsize)
        self.EndBatch()

It resizes the rows and columns when I resize the frame but the grid itself
stays the same size and the remaining spaced is filled in with the
wxGrid background colour. The columns and rows are resized correctly.

···

_______
original |__|__|###
  grid ->|__|__|### <- wxGrid background colour
         >__|__|###
         ##########

It seems like something like UpdateDimensions should be called but
that method doesn't exist, and nothing else in grid.i seems to be
relevant.

wxPython 2.2.5, wxGTK 2.2.6, Python 2.0

Other than this little problem wxPython is sublime. My thanks to the
authors.

Ross Brattain
netmgr@canterburycrest.org

I am attempting to create a wxGrid that automatically sizes the
rows/cols evenly on resize.

        EVT_SIZE(self, self.OnGridSize)

    def OnGridSize(self, evt):
        self.SetSize(evt.GetSize())
        self.SetMargins(0,0)
        colsize = (evt.GetSize().GetWidth() - self.GetRowLabelSize()) /

self.cols

        rowsize = (evt.GetSize().GetHeight() - self.GetColLabelSize()) /

self.rows

        self.BeginBatch()
        for c in range(self.cols):
            self.SetColSize(c, colsize)
        for r in range(self.rows):
            self.SetRowSize(r, rowsize)
        self.EndBatch()

You need to let the wxGrid also process the event, so add a call to
evt.Skip().

···

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