]>
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 #----------------------------------------------------------------------------
12 <B>wxMaskedCtrl</B> is actually a factory function for several types of
16 <LI><b>wxMaskedTextCtrl</b> - standard masked edit text box</LI>
17 <LI><b>wxMaskedComboBox</b> - adds combobox capabilities</LI>
18 <LI><b>wxIpAddrCtrl</b> - adds logical input semantics for IP address entry</LI>
19 <LI><b>wxTimeCtrl</b> - special subclass handling lots of time formats as values</LI>
20 <LI><b>wxMaskedNumCtrl</b> - special subclass handling numeric values</LI>
23 <B>wxMaskedCtrl</B> works by looking for a special <b><i>controlType</i></b>
24 parameter in the variable arguments of the control, to determine
25 what kind of instance to return.
26 controlType can be one of:
28 controlTypes.MASKEDTEXT
29 controlTypes.MASKEDCOMBO
34 These constants are also available individually, ie, you can
35 use either of the following:
37 from wxPython.wx.lib.maskedctrl import wxMaskedCtrl, MASKEDCOMBO, MASKEDTEXT, NUMBER
38 from wxPython.wx.lib.maskedctrl import wxMaskedCtrl, controlTypes
40 If not specified as a keyword argument, the default controlType is
41 controlTypes.MASKEDTEXT.
43 Each of the above classes has its own unique arguments, but wxMaskedCtrl
44 provides a single "unified" interface for masked controls. wxMaskedTextCtrl,
45 wxMaskedComboBox and wxIpAddrCtrl are all documented below; the others have
46 their own demo pages and interface descriptions.
50 from wxPython
.lib
.maskededit
import wxMaskedTextCtrl
, wxMaskedComboBox
, wxIpAddrCtrl
51 from wxPython
.lib
.maskednumctrl
import wxMaskedNumCtrl
52 from wxPython
.lib
.timectrl
import wxTimeCtrl
55 # "type" enumeration for class instance factory function
64 MASKEDTEXT
= MASKEDTEXT
65 MASKEDCOMBO
= MASKEDCOMBO
71 def wxMaskedCtrl( *args
, **kwargs
):
73 Actually a factory function providing a unifying
74 interface for generating masked controls.
76 if not kwargs
.has_key('controlType'):
77 controlType
= MASKEDTEXT
79 controlType
= kwargs
['controlType']
80 del kwargs
['controlType']
82 if controlType
== MASKEDTEXT
:
83 return wxMaskedTextCtrl(*args
, **kwargs
)
85 elif controlType
== MASKEDCOMBO
:
86 return wxMaskedComboBox(*args
, **kwargs
)
88 elif controlType
== IPADDR
:
89 return wxIpAddrCtrl(*args
, **kwargs
)
91 elif controlType
== TIME
:
92 return wxTimeCtrl(*args
, **kwargs
)
94 elif controlType
== NUMBER
:
95 return wxMaskedNumCtrl(*args
, **kwargs
)
99 "invalid controlType specified: %s" % repr(controlType
))