grid in a notebook (sizer question)

Hello,

This code adds a panel to a notebook:

        pnl = PanelDefaultTablespaceEditor(self.notebook)
        self.pnlTablespace = pnl
        self.notebook.AddPage(pnl,_('Tablespace mapping'),imageId='tblspace')

This is the code for the panel:

class PanelDefaultTablespaceEditor(wx.Panel):
    def __init__(self,*args,**kwargs):
        super(wx.Panel,self).__init__(*args,**kwargs)
        sizer = self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)
        self.grid = grid = Grid(parent=self,size=(200,200))
        grid.CreateGrid(2,2)
        grid.SetRowSize( 0, 60 );
        grid.SetColSize( 0, 180 );
        grid.SetColLabelValue(0,"Logical tablespace name")
        grid.SetColLabelValue(1,"Physical tablespace name")
        grid.AutoSizeColumns(True)
        grid.AutoSizeRows(True)
        sizer.Add(grid,proportion=0,flag=wx.EXPAND) # Adding the grid to the sizer

My problem is that the size of the grid is always (200,200).
How can I have the panel (and the grid inside) occupy all available space on the notebook page?
(Probably this is a dumb question. I was trying to solve this but it is too late here to think... )

Thanks,

   Les

Have you tried giving the 'proportion' a value of 1?
Have you tried removing the original 'self.SetSizer()' call and
replacing it with
          self.SetSizerAndFit(sizer)
After the last sizer.Add() call?

- Josiah

···

Laszlo Zsolt Nagy <gandalf@designaproduct.biz> wrote:

  Hello,

This code adds a panel to a notebook:

        pnl = PanelDefaultTablespaceEditor(self.notebook)
        self.pnlTablespace = pnl
        self.notebook.AddPage(pnl,_('Tablespace
mapping'),imageId='tblspace')

This is the code for the panel:

class PanelDefaultTablespaceEditor(wx.Panel):
    def __init__(self,*args,**kwargs):
        super(wx.Panel,self).__init__(*args,**kwargs)
        sizer = self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)
        self.grid = grid = Grid(parent=self,size=(200,200))
        grid.CreateGrid(2,2)
        grid.SetRowSize( 0, 60 );
        grid.SetColSize( 0, 180 );
        grid.SetColLabelValue(0,"Logical tablespace name")
        grid.SetColLabelValue(1,"Physical tablespace name")
        grid.AutoSizeColumns(True)
        grid.AutoSizeRows(True)
        sizer.Add(grid,proportion=0,flag=wx.EXPAND) # Adding the grid
to the sizer

Have you tried giving the 'proportion' a value of 1?

Yes, but it did not work.

Have you tried removing the original 'self.SetSizer()' call and
replacing it with
         self.SetSizerAndFit(sizer)
After the last sizer.Add() call?

Yes, but it did not work.

Here is a screenshot how it loosk if I call "SetSizerAndFit(sizer)" after adding the grid with proportion=1:

http://mess.hu/download/python/grid_problem.jpg

What I do now is:

        self.Bind(
            wx.EVT_SIZE,
            self.OnSize,
            self
        )

and then:

    def OnSize(self,event):
        self.grid.SetSize(self.GetSize())
        event.Skip()

but this is very ugly. I should be able to achieve the same with sizers. Any ideas?

Thanks,

   Les

>Have you tried removing the original 'self.SetSizer()' call and
>replacing it with
> self.SetSizerAndFit(sizer)
>After the last sizer.Add() call?
>
>
Yes, but it did not work.

What about:
        sizer.Layout()
        self.SetSizer(sizer)

What I do now is:

        self.Bind(
            wx.EVT_SIZE,
            self.OnSize,
            self
        )

and then:

    def OnSize(self,event):
        self.grid.SetSize(self.GetSize())
        event.Skip()

but this is very ugly. I should be able to achieve the same with sizers.
Any ideas?

I've had to do the above on occasion with other things, though it has
been quite a while.

- Josiah

···

Laszlo Zsolt Nagy <gandalf@designaproduct.biz> wrote: