Attachment 'DUAL_CONTROL_CLASS_1.PY'

Download

#!/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

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-03 00:02:35, 0.8 KB) [[attachment:AddLinearSpacer.PY]]
  • [get | view] (2010-09-27 21:22:43, 0.6 KB) [[attachment:AddLinearSpacer.py]]
  • [get | view] (2010-10-03 00:07:55, 15.1 KB) [[attachment:DUAL_CONTROL_CLASS_1.PNG]]
  • [get | view] (2010-10-03 16:43:05, 2.9 KB) [[attachment:DUAL_CONTROL_CLASS_1.PY]]
  • [get | view] (2010-10-03 00:08:04, 17.3 KB) [[attachment:DUAL_CONTROL_CLASS_2.PNG]]
  • [get | view] (2010-10-03 16:42:58, 4.3 KB) [[attachment:DUAL_CONTROL_CLASS_2.PY]]
  • [get | view] (2010-10-03 00:08:11, 18.1 KB) [[attachment:DUAL_CONTROL_CLASS_3.PNG]]
  • [get | view] (2010-10-03 16:43:16, 4.4 KB) [[attachment:DUAL_CONTROL_CLASS_3.PY]]
  • [get | view] (2010-10-03 16:13:27, 21.6 KB) [[attachment:DUAL_CONTROL_CLASS_4.PNG]]
  • [get | view] (2010-10-03 16:44:24, 5.3 KB) [[attachment:DUAL_CONTROL_CLASS_4.PY]]
  • [get | view] (2010-09-30 16:11:37, 42.7 KB) [[attachment:DUAL_SIZER_SKETCH.PNG]]
  • [get | view] (2010-09-30 17:37:50, 6.5 KB) [[attachment:DUAL_SIZER_SKETCH_ANNO.PNG]]
  • [get | view] (2010-09-30 17:46:56, 13.6 KB) [[attachment:DUAL_SIZER_SKETCH_EXPLODED.PNG]]
  • [get | view] (2010-09-28 18:55:07, 4.2 KB) [[attachment:LIGHTBULB.64x64.PNG]]
 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.