]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/lib/maskedctrl.py
1 #----------------------------------------------------------------------------
2 # Name: wxPython.lib.maskedctrl.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)
16 <B>wxMaskedCtrl</B> is actually a factory function for several types of
20 <LI><b>wxMaskedTextCtrl</b> - standard masked edit text box</LI>
21 <LI><b>wxMaskedComboBox</b> - adds combobox capabilities</LI>
22 <LI><b>wxIpAddrCtrl</b> - adds logical input semantics for IP address entry</LI>
23 <LI><b>wxTimeCtrl</b> - special subclass handling lots of time formats as values</LI>
24 <LI><b>wxMaskedNumCtrl</b> - special subclass handling numeric values</LI>
27 <B>wxMaskedCtrl</B> works by looking for a special <b><i>controlType</i></b>
28 parameter in the variable arguments of the control, to determine
29 what kind of instance to return.
30 controlType can be one of:
32 controlTypes.MASKEDTEXT
33 controlTypes.MASKEDCOMBO
38 These constants are also available individually, ie, you can
39 use either of the following:
41 from wxPython.wx.lib.maskedctrl import wxMaskedCtrl, MASKEDCOMBO, MASKEDTEXT, NUMBER
42 from wxPython.wx.lib.maskedctrl import wxMaskedCtrl, controlTypes
44 If not specified as a keyword argument, the default controlType is
45 controlTypes.MASKEDTEXT.
47 Each of the above classes has its own unique arguments, but wxMaskedCtrl
48 provides a single "unified" interface for masked controls. wxMaskedTextCtrl,
49 wxMaskedComboBox and wxIpAddrCtrl are all documented below; the others have
50 their own demo pages and interface descriptions.
54 from wx
.lib
.maskededit
import wxMaskedTextCtrl
, wxMaskedComboBox
, wxIpAddrCtrl
55 from wx
.lib
.maskednumctrl
import wxMaskedNumCtrl
56 from wx
.lib
.timectrl
import wxTimeCtrl
59 # "type" enumeration for class instance factory function
68 MASKEDTEXT
= MASKEDTEXT
69 MASKEDCOMBO
= MASKEDCOMBO
75 def wxMaskedCtrl( *args
, **kwargs
):
77 Actually a factory function providing a unifying
78 interface for generating masked controls.
80 if not kwargs
.has_key('controlType'):
81 controlType
= MASKEDTEXT
83 controlType
= kwargs
['controlType']
84 del kwargs
['controlType']
86 if controlType
== MASKEDTEXT
:
87 return wxMaskedTextCtrl(*args
, **kwargs
)
89 elif controlType
== MASKEDCOMBO
:
90 return wxMaskedComboBox(*args
, **kwargs
)
92 elif controlType
== IPADDR
:
93 return wxIpAddrCtrl(*args
, **kwargs
)
95 elif controlType
== TIME
:
96 return wxTimeCtrl(*args
, **kwargs
)
98 elif controlType
== NUMBER
:
99 return wxMaskedNumCtrl(*args
, **kwargs
)
102 raise AttributeError(
103 "invalid controlType specified: %s" % repr(controlType
))