X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8b9a4190f70909de9568f45389e7aa3ecbc66b8a..8f8c4b40456b5a4ef56a704c69570c7a1c86e714:/wxPython/wx/lib/maskedctrl.py diff --git a/wxPython/wx/lib/maskedctrl.py b/wxPython/wx/lib/maskedctrl.py index 4e5aaafbc4..d5537775ae 100644 --- a/wxPython/wx/lib/maskedctrl.py +++ b/wxPython/wx/lib/maskedctrl.py @@ -1,8 +1,109 @@ +#---------------------------------------------------------------------------- +# Name: wxPython.lib.maskedctrl.py +# Author: Will Sadkin +# Created: 09/24/2003 +# Copyright: (c) 2003 by Will Sadkin +# RCS-ID: $Id$ +# License: wxWindows license +#---------------------------------------------------------------------------- +# 12/09/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Updated for wx namespace (minor) +# +# 12/20/2003 - Jeff Grimmett (grimmtooth@softhome.net) +# +# o Removed wx prefix +# + +"""
++MaskedCtrl is actually a factory function for several types of +masked edit controls: +
+
+MaskedCtrl works by looking for a special controlType +parameter in the variable arguments of the control, to determine +what kind of instance to return. +controlType can be one of: +
+ controlTypes.MASKEDTEXT + controlTypes.MASKEDCOMBO + controlTypes.IPADDR + controlTypes.TIME + controlTypes.NUMBER ++These constants are also available individually, ie, you can +use either of the following: +
+ from wxPython.wx.lib.maskedctrl import MaskedCtrl, MASKEDCOMBO, MASKEDTEXT, NUMBER + from wxPython.wx.lib.maskedctrl import MaskedCtrl, controlTypes ++If not specified as a keyword argument, the default controlType is +controlTypes.MASKEDTEXT. +
+Each of the above classes has its own unique arguments, but MaskedCtrl +provides a single "unified" interface for masked controls. MaskedTextCtrl, +MaskedComboBox and IpAddrCtrl are all documented below; the others have +their own demo pages and interface descriptions. + +""" + +from wx.lib.maskededit import MaskedTextCtrl, MaskedComboBox, IpAddrCtrl +from wx.lib.maskednumctrl import MaskedNumCtrl +from wx.lib.timectrl import TimeCtrl + + +# "type" enumeration for class instance factory function +MASKEDTEXT = 0 +MASKEDCOMBO = 1 +IPADDR = 2 +TIME = 3 +NUMBER = 4 + +# for ease of import +class controlTypes: + MASKEDTEXT = MASKEDTEXT + MASKEDCOMBO = MASKEDCOMBO + IPADDR = IPADDR + TIME = TIME + NUMBER = NUMBER + + +def MaskedCtrl( *args, **kwargs): + """ + Actually a factory function providing a unifying + interface for generating masked controls. + """ + if not kwargs.has_key('controlType'): + controlType = MASKEDTEXT + else: + controlType = kwargs['controlType'] + del kwargs['controlType'] + + if controlType == MASKEDTEXT: + return MaskedTextCtrl(*args, **kwargs) + + elif controlType == MASKEDCOMBO: + return MaskedComboBox(*args, **kwargs) + + elif controlType == IPADDR: + return IpAddrCtrl(*args, **kwargs) + + elif controlType == TIME: + return TimeCtrl(*args, **kwargs) + + elif controlType == NUMBER: + return MaskedNumCtrl(*args, **kwargs) + + else: + raise AttributeError( + "invalid controlType specified: %s" % repr(controlType)) -"""Renamer stub: provides a way to drop the wx prefix from wxPython objects.""" -from wx import _rename -from wxPython.lib import maskedctrl -_rename(globals(), maskedctrl.__dict__, modulename='lib.maskedctrl') -del maskedctrl -del _rename