]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/lib/masked/ctrl.py
   1 #---------------------------------------------------------------------------- 
   2 # Name:         wxPython.lib.masked.ctrl.py 
   5 # Copyright:   (c) 2003 by Will Sadkin 
   7 # License:     wxWindows license 
   8 #---------------------------------------------------------------------------- 
   9 # 12/09/2003 - Jeff Grimmett (grimmtooth@softhome.net) 
  11 # o Updated for wx namespace (minor) 
  13 # 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) 
  20 *masked.Ctrl* is actually a factory function for several types of 
  23     =================  ========================================================= 
  24     masked.TextCtrl     standard masked edit text box 
  25     masked.ComboBox     adds combobox capabilities 
  26     masked.IpAddrCtrl   adds logical input semantics for IP address entry 
  27     masked.TimeCtrl     special subclass handling lots of time formats as values 
  28     masked.NumCtrl      special subclass handling numeric values 
  29     =================  ========================================================= 
  31 masked.Ctrl works by looking for a special *controlType* 
  32 parameter in the variable arguments of the control, to determine 
  33 what kind of instance to return. 
  34 controlType can be one of:: 
  42 These constants are also available individually, ie, you can 
  43 use either of the following:: 
  45     from wxPython.wx.lib.masked import Ctrl, COMBO, TEXT, NUMBER, TIME 
  46     from wxPython.wx.lib.masked import Ctrl, controlTypes 
  48 If not specified as a keyword argument, the default controlType is 
  51 Each of the above classes has its own unique arguments, but Masked.Ctrl 
  52 provides a single "unified" interface for masked controls. 
  57 from wx
.lib
.masked   
import TextCtrl
, ComboBox
, IpAddrCtrl
 
  58 from wx
.lib
.masked   
import NumCtrl
 
  59 from wx
.lib
.masked   
import TimeCtrl
 
  62 # "type" enumeration for class instance factory function 
  78 def Ctrl( *args
, **kwargs
): 
  80     Actually a factory function providing a unifying 
  81     interface for generating masked controls. 
  83     if not kwargs
.has_key('controlType'): 
  86         controlType 
= kwargs
['controlType'] 
  87         del kwargs
['controlType'] 
  89     if controlType 
== TEXT
: 
  90         return TextCtrl(*args
, **kwargs
) 
  92     elif controlType 
== COMBO
: 
  93         return ComboBox(*args
, **kwargs
) 
  95     elif controlType 
== IPADDR
: 
  96         return IpAddrCtrl(*args
, **kwargs
) 
  98     elif controlType 
== TIME
: 
  99         return TimeCtrl(*args
, **kwargs
) 
 101     elif controlType 
== NUMBER
: 
 102         return NumCtrl(*args
, **kwargs
) 
 105         raise AttributeError( 
 106             "invalid controlType specified: %s" % repr(controlType
))