gridSizer inside a panel element

Mike Driscoll kyosohma at gmail.com
Fri Aug 22 17:30:13 CEST 2008


On Aug 22, 8:51 am, Iain King <iaink... at gmail.com> wrote:
> On Aug 22, 2:09 pm, Gandalf <goldn... at gmail.com> wrote:
>
>
>
> > why when I try to insert gridSizer to a panel which already inside
> > another panel the gridSizer doesn't work?
>
> > this is the code:
>
> > panel3= wx.Panel(self, -1, (0, 60), size=(400, 240) ,
> > style=wx.SIMPLE_BORDER);
> >         panel3.SetBackgroundColour('#dadadb')
> >         panel = wx.Panel(panel3, wx.ID_ANY, style=wx.SIMPLE_BORDER,
> > size=(150, 60))
> >         panel.SetBackgroundColour("#fffFFF")
>
> >         bmp = wx.ArtProvider.GetBitmap(wx.ART_TIP, wx.ART_OTHER, (16,
> > 16))
> >         inputIco = wx.StaticBitmap(panel, wx.ID_ANY, bmp)
>
> >         labelThree= wx.StaticText(panel, wx.ID_ANY, 'Hello')
>
> >         label2=wx.StaticText(panel, wx.ID_ANY, 'Pease, Quite, Hello, Shalom')
> >         topSizer  = wx.BoxSizer(wx.VERTICAL)
> >         gridSizer = wx.GridSizer(rows=2, cols=1, hgap=5, vgap=5)
> >         input = wx.BoxSizer(wx.HORIZONTAL)
> >         output = wx.BoxSizer(wx.HORIZONTAL)
>
> >         input.Add((20,20), 1, wx.EXPAND) # this is a spacer
> >         input.Add(inputIco, 0, wx.ALL, 5)
> >         input.Add(labelThree, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
>
> >         output.Add((20,20), 1, wx.EXPAND) # this is a spacer
>
> >         output.Add(label2, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5)
>
> >         gridSizer.Add(input, 0, wx.ALIGN_LEFT)
> >         gridSizer.Add(output, 0, wx.ALIGN_RIGHT)
>
> >         topSizer.Add(gridSizer, 0, wx.ALL|wx.EXPAND, 5)
> >         panel.SetSizer(topSizer)
>
> I'm not sure you can just add sizers together like that.  When I'm
> doing this I'd make panels for each sub-sizer; so input and output
> would be panels rather than the sizers themselves.

<snip>

>
> Iain

Nesting sizers is pretty common, at least it is over at the wxPython
user's group: http://wxpython.org/maillist.php

I do it all the time, myself.

Mike



More information about the Python-list mailing list