]> git.saurik.com Git - wxWidgets.git/blame - wxPython/wx/lib/maskedctrl.py
1.
[wxWidgets.git] / wxPython / wx / lib / maskedctrl.py
CommitLineData
d14a1e28
RD
1#----------------------------------------------------------------------------
2# Name: wxPython.lib.maskedctrl.py
3# Author: Will Sadkin
4# Created: 09/24/2003
5# Copyright: (c) 2003 by Will Sadkin
6# RCS-ID: $Id$
7# License: wxWindows license
8#----------------------------------------------------------------------------
b881fc78
RD
9# 12/09/2003 - Jeff Grimmett (grimmtooth@softhome.net)
10#
11# o Updated for wx namespace (minor)
12#
d14a1e28
RD
13
14"""<html><body>
15<P>
16<B>wxMaskedCtrl</B> is actually a factory function for several types of
17masked edit controls:
18<P>
19<UL>
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>
25</UL>
26<P>
27<B>wxMaskedCtrl</B> works by looking for a special <b><i>controlType</i></b>
28parameter in the variable arguments of the control, to determine
29what kind of instance to return.
30controlType can be one of:
31<PRE><FONT SIZE=-1>
32 controlTypes.MASKEDTEXT
33 controlTypes.MASKEDCOMBO
34 controlTypes.IPADDR
35 controlTypes.TIME
36 controlTypes.NUMBER
37</FONT></PRE>
38These constants are also available individually, ie, you can
39use either of the following:
40<PRE><FONT SIZE=-1>
41 from wxPython.wx.lib.maskedctrl import wxMaskedCtrl, MASKEDCOMBO, MASKEDTEXT, NUMBER
42 from wxPython.wx.lib.maskedctrl import wxMaskedCtrl, controlTypes
43</FONT></PRE>
44If not specified as a keyword argument, the default controlType is
45controlTypes.MASKEDTEXT.
46<P>
47Each of the above classes has its own unique arguments, but wxMaskedCtrl
48provides a single "unified" interface for masked controls. wxMaskedTextCtrl,
49wxMaskedComboBox and wxIpAddrCtrl are all documented below; the others have
50their own demo pages and interface descriptions.
51</body></html>
52"""
53
b881fc78
RD
54from wx.lib.maskededit import wxMaskedTextCtrl, wxMaskedComboBox, wxIpAddrCtrl
55from wx.lib.maskednumctrl import wxMaskedNumCtrl
56from wx.lib.timectrl import wxTimeCtrl
d14a1e28
RD
57
58
59# "type" enumeration for class instance factory function
60MASKEDTEXT = 0
61MASKEDCOMBO = 1
62IPADDR = 2
63TIME = 3
64NUMBER = 4
65
66# for ease of import
67class controlTypes:
68 MASKEDTEXT = MASKEDTEXT
69 MASKEDCOMBO = MASKEDCOMBO
70 IPADDR = IPADDR
71 TIME = TIME
72 NUMBER = NUMBER
73
74
75def wxMaskedCtrl( *args, **kwargs):
76 """
77 Actually a factory function providing a unifying
78 interface for generating masked controls.
79 """
80 if not kwargs.has_key('controlType'):
81 controlType = MASKEDTEXT
82 else:
83 controlType = kwargs['controlType']
84 del kwargs['controlType']
85
86 if controlType == MASKEDTEXT:
87 return wxMaskedTextCtrl(*args, **kwargs)
88
89 elif controlType == MASKEDCOMBO:
90 return wxMaskedComboBox(*args, **kwargs)
91
92 elif controlType == IPADDR:
93 return wxIpAddrCtrl(*args, **kwargs)
94
95 elif controlType == TIME:
96 return wxTimeCtrl(*args, **kwargs)
97
98 elif controlType == NUMBER:
99 return wxMaskedNumCtrl(*args, **kwargs)
100
101 else:
102 raise AttributeError(
103 "invalid controlType specified: %s" % repr(controlType))
8b9a4190 104
8b9a4190 105