#!/usr/bin/python

# DUAL_CONTROL_CLASS_1.PY

import wx
import AddLinearSpacer as als

#------------------------------------------------------------------------------

class TxtCtrlPanel( wx.Panel ) :
    """ A 2-control class with a sizer """
    
    def __init__( self, parent, caption_txt ) :
    
        wx.Panel.__init__( self, parent=parent, id=-1 )
        
        #-----
    
        self.caption_stTxt = wx.StaticText( self, -1, caption_txt )
        self.caption_stTxt.BackgroundColour = ( 'wHIte' )
        
        self.list_txtCtrl = wx.TextCtrl( self, -1, style=wx.TE_MULTILINE, size=(200, 150) )
        
        #-----
        
        panel_vertSizer = wx.BoxSizer( wx.VERTICAL )
        
        panel_vertSizer.Add( self.caption_stTxt, proportion=0, flag=wx.CENTER )
        
        als.AddLinearSpacer( panel_vertSizer, 2 )
        
        panel_vertSizer.Add( self.list_txtCtrl,  proportion=0, flag=wx.ALIGN_CENTER )
        
        self.SetSizer( panel_vertSizer )    # Invoke the sizer.
        self.Fit()  # Make "self" (the panel) shrink to the minimum size required by the controls.
        
    #end __init__
    
    #------------------------
    
    def GetControls( self ) :
    
        return self.caption_stTxt, self.list_txtCtrl
    
#end TxtCtrlPanel class

#------------------------------------------------------------------------------

class MainFrame( wx.Frame ) :
    """ A 2-control class with a BoxSizer demo """
        
    def __init__( self ) :
        
        #-----  Configure the Frame.
        
        wx.Frame.__init__ ( self, parent=None, title='DUAL_CONTROL_CLASS_1.PY', 
                            size=(400, 300), style=wx.DEFAULT_FRAME_STYLE )
        self.Position = (100, 0)
        
        # A panel is needed for tab-traversal and platform background color capabilities.
        # The first control instantiated in a Frame automatically expands 
        #   to the Frame's client size.  This is unique to Frames.
        frm_pnl = wx.Panel( self )
        frm_pnl.BackgroundColour = (250, 250, 150)         # yellow
        
        #-----  Create the controls
        
        txtCtl_panel_1 = TxtCtrlPanel( frm_pnl, 'My TextCtrl Caption #1' )
        stTxt_1, txtCtl_1 = txtCtl_panel_1.GetControls()
        
        #-----  Create the sizer and add the controls to it.
        
        allCtrls_vertSizer = wx.BoxSizer( wx.HORIZONTAL )
        
        #----- Invoke the sizer via its container.
        
        frm_pnl.SetSizer( allCtrls_vertSizer )
        frm_pnl.Layout()                        # self.Fit()  # always use one or the other
        
    #end __init__

#end MainFrame class

#==============================================================================

if __name__ == '__main__' :

    app = wx.PySimpleApp( redirect=False )
    appFrame = MainFrame().Show()
    app.MainLoop()

#end if
