#/usr/bin/env python

# MultipleControlsPanels_Demo.py

"""
Demo that graphically shows the assembly of a GUI using multiple panels
each of which has multiple controls in them. Each panel is colored differently
and is labeled with its class name to distinguish them.

Ray Pasco
pascor(at)verizon(dot)net
2010-10-17
"""

import wx
import PanelControls    as pc

#------------------------------------------------------------------------------

# This list gets used several times in controls thay provide multiple selections.
CHOICES_LIST = [ 'Zero', 'One', 'Two',  'Three',  'Four', 
                 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten' ]

#------------------------------------------------------------------------------

class MainFrame( wx.Frame ) :
        
    #-----  Configure the Frame.
        
    def __init__( self ) :
        
        wx.Frame.__init__ ( self, None, -1, title='MULTIPLE_CONTROLS_PANELS_TEST.PY', 
                            style=wx.DEFAULT_FRAME_STYLE )
        self.Position = (0, 0)
        
        # A panel is needed for tab-traversal and uniform 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 = (235, 230, 220)      # BEIGE
        
        #-----
        
        txtButtonRadio_pnl = pc.TextButtonRadioPanel( parent=frm_pnl, 
                                                      txtCtl_list=CHOICES_LIST, 
                                                      radBtn_list=CHOICES_LIST, 
                                                      bgColor=(250, 220, 150) )     # pale orange
        
        comboSpinSliderCheck_pnl = pc.ComboSpinSliderCheckPanel( frm_pnl, 
                                                                 CHOICES_LIST, 
                                                                 CHOICES_LIST, 
                                                                 (210, 210, 230), 
                                                                )
        
        #---- Use a single sizer to center both controls panels.
        self.frmPnl_vertSizer = wx.BoxSizer( wx.VERTICAL )
        
        self.frmPnl_vertSizer.AddStretchSpacer( prop=1 )
        self.frmPnl_vertSizer.Add( txtButtonRadio_pnl,       flag=wx.ALIGN_CENTER )
        self.frmPnl_vertSizer.Add( comboSpinSliderCheck_pnl, flag=wx.CENTRE )    # synonym
        self.frmPnl_vertSizer.AddStretchSpacer( prop=1 )
        self.frmPnl_vertSizer.Layout()        
        frm_pnl.SetSizer( self.frmPnl_vertSizer )
        
        #-----  Set the Frame size and a minimum Frame size. 
        #       This can not be done in __init__.
        # The Frame is constructed after __init__ and this results in a wx.EVT_SIZE.
        wx.CallAfter( self.SetFrameSize )
        
    #end __init__
    
    #-----
    
    def SetFrameSize( self ) :
        """ 
        Set a fixed minimum Frame client size to the sizer's minimum size.
        
        Set the initial frame client to the sizer's min size + a 10 pixel border.
        The sizer will always center its contents within the Frame.
        """
        frmPnlMinSizeX, frmPnlMinSizeY = self.frmPnl_vertSizer.GetMinSize()
        self.MinClientSize = (frmPnlMinSizeX,    frmPnlMinSizeY   )
        self.ClientSize    = (frmPnlMinSizeX+20, frmPnlMinSizeY+20)
        
    #end def
    
#end MainFrame class

#==============================================================================

if __name__ == '__main__' :

    app = wx.PySimpleApp( redirect=False )
    appFrame = MainFrame().Show()
    app.MainLoop()

#end if
