self.grid has 3 columns, and I want to self.grid full filled in it’s parent.
means, 3 columns were auto expand based on parent’s width, not the value length in it.
You can create an event handler bound to the grid's EVT_SIZE event, and in that handler get the new current size of the grid and using that value set the size of each of the columns using SetColSize. Don't forget to account for the width of the row labels, leave room for the vertical scrollbar, and also you should call event.Skip() so the grid's default event handler will still be called.
···
On 2/8/12 9:05 AM, 月忧茗 wrote:
Hi,
I defined a wx.grid.Grid object,
and then I added this object into a StaticBoxSizer.
self.grid has 3 columns, and I want to self.grid full filled in it's parent.
means, 3 columns were auto expand based on parent's width, not the
value length in it.
and then I added this object into a StaticBoxSizer.
some code like bellow:
class DataPanel(wx.Panel):
…
self.init_test_grid()
_box = wx.StaticBox(self, -1, ‘Box header’)
sizer_wrap = wx.StaticBoxSizer(_box)
sizer_wrap.Add(self.grid, 1, wx.EXPAND)
self.SetSizer(sizer_wrap)
self.grid has 3 columns, and I want to self.grid full filled in it’s parent.
means, 3 columns were auto expand based on parent’s width, not the
value length in it.
How can I do this.
Please Help.
You can create an event handler bound to the grid’s EVT_SIZE event, and in that handler get the new current size of the grid and using that value set the size of each of the columns using SetColSize. Don’t forget to account for the width of the row labels, leave room for the vertical scrollbar, and also you should call event.Skip() so the grid’s default event handler will still be called.