TextCtrl fully expanding at program start

Discussion in 'Python' started by alex, Feb 27, 2009.

  1. alex

    alex Guest

    Hi all
    I have a gridsizer consisting of two vertically stacked panels, one
    with a StaticBox and the other with a TextCtrl.
    I would like that the TextCtrl expands at program start fully to the
    allocated panel size (lower panel of gridSizer).
    Instead of like now, fully expanding in the width but not exapnding in
    the height direction (two lines high).

    I am currently running in circles so maybe can anybody help me?
    See below for my best effort (OS WinXP, Python 2.5).

    Thank you, regards Alex



    import wx

    class Frame(wx.Frame):
    def __init__(self, title, pos, size):
    wx.Frame.__init__(self, None, -1, title, pos, size)

    self.panel = wx.Panel(self)
    self.panel.SetBackgroundColour(wx.Colour(220, 220, 220))

    box1 = wx.StaticBox(self.panel, -1, "Program Preferences")
    box2 = wx.TextCtrl(self.panel, -1, size=(-1,-1),style =
    wx.TE_MULTILINE|wx.TE_READONLY)


    gs = wx.GridSizer(2, 1, 0, 0)
    windowOneSizer = wx.BoxSizer(wx.VERTICAL)
    windowTwoSizer = wx.BoxSizer(wx.VERTICAL)

    windowOneSizer.Add(box1, 0, wx.ALL|wx.EXPAND, 0)
    windowTwoSizer.Add(box2, 0, wx.ALL|wx.EXPAND, 0)

    gs.Add(windowOneSizer, 0, wx.ALL|wx.EXPAND, 2)
    gs.Add(windowTwoSizer, 0, wx.ALL|wx.EXPAND, 2)

    self.panel.SetSizer(gs)
    self.Centre()
    self.Show(True)


    class App(wx.App):
    def OnInit(self):
    frame = Frame("My Frame", (100, 100), (400, 250))
    frame.Show()
    self.SetTopWindow(frame)
    return True
    #
    #
    if __name__ == '__main__':
    #
    app = App()
    app.MainLoop()
    #
    #
     
    alex, Feb 27, 2009
    #1
    1. Advertising

  2. 2009/2/27 alex <>:
    > Hi all
    > I have a gridsizer consisting of two vertically stacked panels, one
    > with a StaticBox and the other with a TextCtrl.
    > I would like that the TextCtrl expands at program start fully to the
    > allocated panel size (lower panel of gridSizer).
    > Instead of like now, fully expanding in the width but not exapnding in
    > the height direction (two lines high).

    ....
    >


    Hi,
    changing the proportion for adding the textctrl into the sizer to 1
    should expand it to the lower half of the panel.

    try changing:
    windowTwoSizer.Add(box2, 0, wx.ALL|wx.EXPAND, 0)
    TO:
    windowTwoSizer.Add(box2, 1, wx.ALL|wx.EXPAND, 0)

    See
    http://www.wxpython.org/docs/api/wx.Sizer-class.html#Add
    for the options for adding into the sizer.

    hth
    vbr
     
    Vlastimil Brom, Feb 27, 2009
    #2
    1. Advertising

  3. alex

    alex Guest

    On 27 Feb., 15:14, Vlastimil Brom <> wrote:
    > 2009/2/27 alex <>:
    >
    > > Hi all
    > > I have a gridsizer consisting of two vertically stacked panels, one
    > > with a StaticBox and the other with a TextCtrl.
    > > I would like that the TextCtrl expands at program start fully to the
    > > allocated panel size (lower panel of gridSizer).
    > > Instead of like now, fully expanding in the width but not exapnding in
    > > the height direction (two lines high).

    > ...
    >
    > Hi,
    > changing the proportion for adding the textctrl into the sizer to 1
    > should expand it to the lower half of the panel.
    >
    > try changing:
    >         windowTwoSizer.Add(box2, 0, wx.ALL|wx.EXPAND, 0)
    > TO:
    >         windowTwoSizer.Add(box2, 1, wx.ALL|wx.EXPAND, 0)
    >
    > Seehttp://www.wxpython.org/docs/api/wx.Sizer-class.html#Add
    > for the options for adding into the sizer.
    >
    > hth
    >    vbr


    Hi Vlastimil
    I must have overlooked it. Too much reading and trying...
    Thank you, it works perfect.

    Regards Alex
     
    alex, Feb 27, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. newgene
    Replies:
    0
    Views:
    846
    newgene
    Jul 28, 2003
  2. Logan
    Replies:
    3
    Views:
    451
    Edward K. Ream
    Dec 2, 2003
  3. Hako
    Replies:
    6
    Views:
    3,708
    Frank Millman
    Jan 20, 2006
  4. Simon Hibbs

    TextCtrl focus events in wxWidgets

    Simon Hibbs, Jul 19, 2006, in forum: Python
    Replies:
    12
    Views:
    13,883
    Frank Millman
    Jul 19, 2006
  5. abcd
    Replies:
    10
    Views:
    752
    Peter Decker
    Nov 1, 2006
Loading...

Share This Page