wxgrid not resizing

for i in xrange(len(self.controls)):
> pnl = wx.Panel(self.tab1, -1)
> bs = wx.StaticBox(pnl,-1, 'label)
> sz = wx.StaticBoxSizer(bs, wx.VERTICAL)
> tmpCtrl = createControl(parent=pnl)
> sz.Add(tmpCtrl, 0, wx.EXPAND | wx.ALL, 3)

You probably just want to use the grid's CreateGrid(rows, cols) method.
I'm not seeing anything else that I do in my programs...

Thank you Mike for your suggestion but I do use CreateGrid(). In my
createControl() function I do that:

def createControl(self, parent):
           tmp = GridLabelCtrl(parent=pnl,
                id=-1,
                label='a label',
                name='a name',
                style=0)
            tmp.CreateGrid(1,3)
            tmp.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.updateValue)
            return tmp

I suppose the problem lies in the gridsizer. If I set that sizer to be 1
column wide the grid displays correctly. If I set it to more than 1
column the space allocated to my subclassed grid is the same but now
there's the horizontal scrollbar cutting the lower part of the grid.
I put 2 images here:
http://www.emmexx.it/varie/grid1.jpg (gridsizer with 1 column)
http://www.emmexx.it/varie/grid2.jpg (gridsizer with 2 columns)

I think there's some command lacking somewhere in my code telling the
sizer: "hey! you must give more vertical space to the grid or it will
have to display a scrollbar".

bye
  maxx

emmexx wrote:

for i in xrange(len(self.controls)):
      

  pnl = wx.Panel(self.tab1, -1)
        bs = wx.StaticBox(pnl,-1, 'label)
        sz = wx.StaticBoxSizer(bs, wx.VERTICAL)
  tmpCtrl = createControl(parent=pnl)
  sz.Add(tmpCtrl, 0, wx.EXPAND | wx.ALL, 3)
        
You probably just want to use the grid's CreateGrid(rows, cols) method. I'm not seeing anything else that I do in my programs...
    
Thank you Mike for your suggestion but I do use CreateGrid(). In my
createControl() function I do that:

def createControl(self, parent):
           tmp = GridLabelCtrl(parent=pnl,
                id=-1,
                label='a label',
                name='a name',
                style=0)
            tmp.CreateGrid(1,3)
            tmp.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.updateValue)
            return tmp

I suppose the problem lies in the gridsizer. If I set that sizer to be 1
column wide the grid displays correctly. If I set it to more than 1
column the space allocated to my subclassed grid is the same but now
there's the horizontal scrollbar cutting the lower part of the grid.
I put 2 images here:
http://www.emmexx.it/varie/grid1.jpg (gridsizer with 1 column)
http://www.emmexx.it/varie/grid2.jpg (gridsizer with 2 columns)

I think there's some command lacking somewhere in my code telling the
sizer: "hey! you must give more vertical space to the grid or it will
have to display a scrollbar".

bye
  maxx
____________________

Oops...somehow I missed that. You may be able to get the sizer to behave by doing this:

sizer.Add(myGrid, 1, wx.EXPAND | wx.ALL, 5)

The second parameter tells the sizer the proportion of space the widget should take up. So if you set it to one, it will take up all the space minus the minimum needed for whatever other widgets you've added. Of course, the grid itself has a size parameter:

myGrid = wx.grid.Grid(parent, id, wx.DefaultPosition, wx.DefaultSize)

Just pass a tuple of the size you want instead of using wx.DefaultSize. You can probably force it that way. Of course, if the user resizes it too small, the scrollbars will appear again.

···

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org

emmexx wrote:

I suppose the problem lies in the gridsizer. If I set that sizer to be 1
column wide the grid displays correctly. If I set it to more than 1
column the space allocated to my subclassed grid is the same but now
there's the horizontal scrollbar cutting the lower part of the grid.
I put 2 images here:
http://www.emmexx.it/varie/grid1.jpg (gridsizer with 1 column)
http://www.emmexx.it/varie/grid2.jpg (gridsizer with 2 columns)

That is the way that a GridSizer works. Each of the 'cells' in the sizer all have the same size.

BTW, despite the names there is no special relationship between a wx.GridSizer and a wx.grid.Grid widget.

···

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