[wxPython-users] Re: expanding member widgets to be same size
Unknown
mgbg25171 at blueyonder.co.uk
Mon Nov 5 09:33:16 PST 2007
On Mon, 2007-11-05 at 15:17 +0000, Regan Tackett wrote:
> Unknown <mgbg25171 <at> blueyonder.co.uk> writes:
>
> >
> > <code>
> > How can I make the button and textcontrol members (in this class)
> > both expand to have the SAME WIDTH (implying they are part of the
> > same object) that will be commensurate with the width of the largest
> > string ie button title or line in textcontrol.
> >
> > #incomplete snippet
> > class ExpandingTxtCtrl(wx.Panel):
> > def __init__(self, parent,title):
> > wx.Panel.__init__(self, parent, id=-1)
> > self.button = wx.Button(self, -1, title)
> > self.tc = wx.TextCtrl(
> > self, -1,
> > style=wx.TE_MULTILINE,
> > value=""
> > )
> > sz_1 = wx.BoxSizer(wx.VERTICAL)
> > sz_1.Add(self.button, 0, wx.EXPAND)
> > sz_1.Add(self.tc, 0, wx.EXPAND)
> > self.SetSizer(sz_1)
> > self.sz_1 = sz_1
> >
> > Any help much appreciated
> > Dean
>
>
>
> You could use a GridBagSizer. Here's an untested snippet that you can try.
>
>
> class ExpandingTxtCtrl(wx.Panel):
> def __init__(self, parent,title):
> wx.Panel.__init__(self, parent, id=-1)
>
> self.button = wx.Button(self, -1, title)
> self.tc = wx.TextCtrl(
> self, -1,
> style=wx.TE_MULTILINE,
> value=""
> )
> sz_1 = wx.GridBagSizer(hgap = 5, vgap = 5)
> sz_1.Add(self.button, pos = (0, 0), flag = wx.EXPAND)
> sz_1.Add(self.tc, pos = (1, 0), flag = wx.EXPAND)
> self.SetSizer(sz_1)
> self.sz_1 = sz_1
>
>
Regan
my mistake. The combined class I meant
to refer to was a label and listbox combined. This one
works ok. I'll re-post later when I've had another look
at it cos I'm sure I'm using the same sizing technique.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
>
>
More information about the wxpython-users
mailing list