Attachment 'AddSpacer.py'

Download

   1 import wx
   2 
   3 """ 
   4 AddSpacer
   5 
   6 An intelligent function to add a variety of spacers.  
   7 Interger values of zero or greater are valid.
   8 
   9 Syntax:
  10     AddSpacer( sizerName, reqArg, rectYarg )
  11 
  12 A) reqArg is a single integer. Inserts a one-demensional spacer
  13    along the sizer's major axis. This is a safe alternative 
  14    to the sizer.AddSpacer( n ) method which inserts a square 
  15    shaped spacer which can unintentionally interfere with 
  16    adjacent controls stacked along one or both of the 
  17    sizer's minor axis.
  18 
  19 B) reqArg is a 2-tuple of integers. Inserts a rectanguler spacer.
  20    E.g.:   (20, 30)
  21    Inserts a rectanguler spacer.
  22    
  23 C) reqArg and optArg are integer arguments.
  24    E.g.:   20, 30
  25    Inserts a rectanguler spacer.
  26    
  27 
  28 Ray Pasco
  29 2010-09-25-Sat__PM-03-14-19__September
  30 """
  31 
  32 import os, sys
  33 import wx
  34 
  35 def AddSpacer( boxsizer, reqArg, optArg=None ) :
  36     """ A smart spacer for use with any BoxSizer """
  37     
  38     if (type( reqArg ) == type( 123 )) and (optArg == None) :
  39         
  40         orientation = boxsizer.GetOrientation()
  41         if   (orientation == wx.HORIZONTAL) :
  42             boxsizer.Add( (reqArg, 0) )
  43             
  44         elif (orientation == wx.VERTICAL) :
  45             boxsizer.Add( (0, reqArg) )
  46         #end if
  47             
  48     elif (type( reqArg ) == type( (123, 123) ))  and (optArg == None) and  \
  49          (type( reqArg[0] ) == type( 123 ))      and (type( reqArg[1] ) == type( 123 )) :
  50     
  51         boxsizer.Add( reqArg )
  52         
  53     elif (type( reqArg ) == type( 123 )) and (type( optArg ) == type( 123 )) :
  54     
  55         boxsizer.Add( (reqArg, optArg) )
  56         
  57     else :
  58         print
  59         print '####  AddSpacer():    Argument Types are Not Recognized.'
  60         sys.exit(1)
  61     #end if
  62 
  63 #end def
  64 
  65 #------------------------------------------------------------------------------
  66 
  67 """ 
  68 AddLinearSpacer
  69 
  70 This is included for backward compatibility in the demo apps.
  71 
  72 Simple, foolproof, and intelligent function to properly insert 
  73 a variety of spacers.  Interger values of zero or greater are valid.
  74 
  75 Syntax:
  76     AddLinearSpacer( sizerName, int )
  77 
  78 Ray Pasco
  79 2010-09-25-Sat__PM-03-14-19__September
  80 """
  81 
  82 def AddLinearSpacer( boxsizer, pixelSpacing ) :
  83     """ 
  84     A one-dimensional spacer for use with any BoxSizer.
  85     """
  86 
  87     orientation = boxsizer.GetOrientation()
  88     if   (orientation == wx.HORIZONTAL) :
  89         boxsizer.Add( (pixelSpacing, 0) )
  90 
  91     elif (orientation == wx.VERTICAL) :
  92         boxsizer.Add( (0, pixelSpacing) )
  93     #end if
  94 
  95 #end def

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.