Keeping TextCtrl in StaticBox w/o Absolute Positioning

Here's a question I cannot answer from reading the web site, wiki, or the
wxWidgets book: how to keep a wx.TextCtrl within a wx.StaticBox using sizers
rather than absolute positioning.

   The two lines of code are:

     stBox = wx.StaticBox(self, wx.ID_ANY, label='Run Status', size=wx.Size(525, 150),
                          style=wx.RAISED_BORDER)
     runStatusTxt = wx.TextCtrl(self, wx.ID_ANY, size=wx.Size(500, 125), style=wx.VSCROLL|
                                wx.TE_READONLY|wx.TE_MULTILINE|wx.TE_DONTWRAP|
                                wx.TAB_TRAVERSAL|wx.RAISED_BORDER|wx.HSCROLL)

and I add them to the same sizer thusly:

     hbox2.Add(stBox, 0, wx.ALL, 2)
     hbox2.Add(runStatusTxt, 0)

   When the application runs, the text control is outside and to the right of
the static box, covering a column of buttons. How do I keep it in the corral
of the static box? Or, is there a way to put a thin, external border and
title on the text control directly?

Thanks,

Rich

···

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863

You have to create a StaticBoxSizer and use the StaticBox as its first
argument. See example below.

HTH

Guido

import wx
            
class MainFrame(wx.Frame):
    def __init__(self, parent, ID, title):
        wx.Frame.__init__(self, parent, ID, title,
                          wx.DefaultPosition, wx.Size(600, 400))
        
        Panel = wx.Panel(self, -1)
        TopSizer = wx.BoxSizer(wx.VERTICAL)
        Panel.SetSizer(TopSizer)
        
        stBox = wx.StaticBox(Panel, wx.ID_ANY, label='Run Status',
                             size=wx.Size(525, 150), style=wx.RAISED_BORDER)
        SBSizer = wx.StaticBoxSizer(stBox, wx.HORIZONTAL)
        runStatusTxt = wx.TextCtrl(Panel, wx.ID_ANY, size=wx.Size(500, 125),
                                   style=wx.VSCROLL | wx.TE_READONLY |
                                   wx.TE_MULTILINE | wx.TE_DONTWRAP |
                                   wx.TAB_TRAVERSAL|wx.RAISED_BORDER|wx.HSCROLL)
        SBSizer.Add(runStatusTxt, 0)
        TopSizer.Add(SBSizer, 0, wx.ALL, 2)
        
class MyApp(wx.App):
    def OnInit(self):
        Frame = MainFrame(None, -1, "Static Box Demo")
        Frame.Show(True)
        self.SetTopWindow(Frame)
        return True

if __name__ == '__main__':
    App = MyApp(0)
    App.MainLoop()

Guido,

   Thank you very much. This does help very much.

Rich

···

On Wed, 30 Nov 2005, Guido Roth wrote:

You have to create a StaticBoxSizer and use the StaticBox as its first
argument. See example below.

--
Richard B. Shepard, Ph.D. | Author of "Quantifying Environmental
Applied Ecosystem Services, Inc. (TM) | Impact Assessments Using Fuzzy Logic"
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863