Attachment 'MultipleControlsPanels_Demo.py'

Download

   1 #/usr/bin/env python
   2 
   3 # MultipleControlsPanels_Demo.py
   4 
   5 """
   6 Demo that graphically shows the assembly of a GUI using multiple panels
   7 each of which has multiple controls in them. Each panel is colored differently
   8 and is labeled with its class name to distinguish them.
   9 
  10 Ray Pasco
  11 pascor(at)verizon(dot)net
  12 2010-10-17
  13 """
  14 
  15 import wx
  16 import PanelControls    as pc
  17 
  18 #------------------------------------------------------------------------------
  19 
  20 # This list gets used several times in controls thay provide multiple selections.
  21 CHOICES_LIST = [ 'Zero', 'One', 'Two',  'Three',  'Four', 
  22                  'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten' ]
  23 
  24 #------------------------------------------------------------------------------
  25 
  26 class MainFrame( wx.Frame ) :
  27         
  28     #-----  Configure the Frame.
  29         
  30     def __init__( self ) :
  31         
  32         wx.Frame.__init__ ( self, None, -1, title='MULTIPLE_CONTROLS_PANELS_TEST.PY', 
  33                             style=wx.DEFAULT_FRAME_STYLE )
  34         self.Position = (0, 0)
  35         
  36         # A panel is needed for tab-traversal and uniform platform background color capabilities.
  37         # The first control instantiated in a Frame automatically expands 
  38         #   to the Frame's client size.  This is unique to Frames.
  39         frm_pnl = wx.Panel( self )
  40         frm_pnl.BackgroundColour = (235, 230, 220)      # BEIGE
  41         
  42         #-----
  43         
  44         txtButtonRadio_pnl = pc.TextButtonRadioPanel( parent=frm_pnl, 
  45                                                       txtCtl_list=CHOICES_LIST, 
  46                                                       radBtn_list=CHOICES_LIST, 
  47                                                       bgColor=(250, 220, 150) )     # pale orange
  48         
  49         comboSpinSliderCheck_pnl = pc.ComboSpinSliderCheckPanel( frm_pnl, 
  50                                                                  CHOICES_LIST, 
  51                                                                  CHOICES_LIST, 
  52                                                                  (210, 210, 230), 
  53                                                                 )
  54         
  55         #---- Use a single sizer to center both controls panels.
  56         self.frmPnl_vertSizer = wx.BoxSizer( wx.VERTICAL )
  57         
  58         self.frmPnl_vertSizer.AddStretchSpacer( prop=1 )
  59         self.frmPnl_vertSizer.Add( txtButtonRadio_pnl,       flag=wx.ALIGN_CENTER )
  60         self.frmPnl_vertSizer.Add( comboSpinSliderCheck_pnl, flag=wx.CENTRE )    # synonym
  61         self.frmPnl_vertSizer.AddStretchSpacer( prop=1 )
  62         self.frmPnl_vertSizer.Layout()        
  63         frm_pnl.SetSizer( self.frmPnl_vertSizer )
  64         
  65         #-----  Set the Frame size and a minimum Frame size. 
  66         #       This can not be done in __init__.
  67         # The Frame is constructed after __init__ and this results in a wx.EVT_SIZE.
  68         wx.CallAfter( self.SetFrameSize )
  69         
  70     #end __init__
  71     
  72     #-----
  73     
  74     def SetFrameSize( self ) :
  75         """ 
  76         Set a fixed minimum Frame client size to the sizer's minimum size.
  77         
  78         Set the initial frame client to the sizer's min size + a 10 pixel border.
  79         The sizer will always center its contents within the Frame.
  80         """
  81         frmPnlMinSizeX, frmPnlMinSizeY = self.frmPnl_vertSizer.GetMinSize()
  82         self.MinClientSize = (frmPnlMinSizeX,    frmPnlMinSizeY   )
  83         self.ClientSize    = (frmPnlMinSizeX+20, frmPnlMinSizeY+20)
  84         
  85     #end def
  86     
  87 #end MainFrame class
  88 
  89 #==============================================================================
  90 
  91 if __name__ == '__main__' :
  92 
  93     app = wx.PySimpleApp( redirect=False )
  94     appFrame = MainFrame().Show()
  95     app.MainLoop()
  96 
  97 #end if

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2010-10-18 04:58:55, 2.5 KB) [[attachment:AddSpacer.py]]
  • [get | view] (2010-11-14 22:48:20, 28.1 KB) [[attachment:MultipleControlsPanels_Demo.png]]
  • [get | view] (2010-10-18 04:59:19, 3.7 KB) [[attachment:MultipleControlsPanels_Demo.py]]
  • [get | view] (2010-11-14 22:48:31, 18.7 KB) [[attachment:PanelControls.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.

NOTE: To edit pages in this wiki you must be a member of the TrustedEditorsGroup.