diff --git a/wx/lib/masked/combobox.py b/wx/lib/masked/combobox.py index 9c518172..f9afb1f7 100644 --- a/wx/lib/masked/combobox.py +++ b/wx/lib/masked/combobox.py @@ -52,7 +52,7 @@ class MaskedComboBoxSelectEvent(wx.PyCommandEvent): class MaskedComboBoxEventHandler(wx.EvtHandler): """ This handler ensures that the derived control can react to events - from the base control before any external handlers run, to ensure + from the base control before any external handlers run, to ensure proper behavior. """ def __init__(self, combobox): @@ -107,7 +107,7 @@ class BaseMaskedComboBox( wx.ComboBox, MaskedEditMixin ): :param string `name`: the window name; :param boolean `setupEventHandling`: setup event handling by default. - """ + """ kwargs['choices'] = choices ## set up maskededit to work with choice list too @@ -136,7 +136,7 @@ class BaseMaskedComboBox( wx.ComboBox, MaskedEditMixin ): self._PostInit(style=style, setupEventHandling=setupEventHandling, name=name, value=value, **kwargs) - + def _PostInit(self, style=wx.CB_DROPDOWN, setupEventHandling = True, ## setup event handling by default): @@ -148,7 +148,7 @@ class BaseMaskedComboBox( wx.ComboBox, MaskedEditMixin ): self.__readonly = style & wx.CB_READONLY == wx.CB_READONLY if not hasattr(self, 'controlInitialized'): - + self.controlInitialized = True ## must have been called via XRC, therefore base class is constructed if 'choices' not in kwargs: choices=[] @@ -218,7 +218,7 @@ class BaseMaskedComboBox( wx.ComboBox, MaskedEditMixin ): # clean up associated event handler object: if self.RemoveEventHandler(self.evt_handler): wx.CallAfter(self.evt_handler.Destroy) - event.Skip() + event.Skip() def _CalcSize(self, size=None): @@ -233,13 +233,13 @@ class BaseMaskedComboBox( wx.ComboBox, MaskedEditMixin ): def SetFont(self, *args, **kwargs): """ Set the font, then recalculate control size, if appropriate. - + see :meth:`ComboBox.SetFont` for valid arguments - + """ wx.ComboBox.SetFont(self, *args, **kwargs) if self._autofit: -## dbg('calculated size:', self._CalcSize()) +## dbg('calculated size:', self._CalcSize()) self.SetClientSize(self._CalcSize()) width = self.GetSize().width height = self.GetBestSize().height @@ -321,11 +321,11 @@ class BaseMaskedComboBox( wx.ComboBox, MaskedEditMixin ): This function redefines the externally accessible :meth:`ComboBox.SetValue` to be a smart "paste" of the text in question, so as not to corrupt the masked control. - + .. note:: - + This must be done in the class derived from the base wx control. - + """ ## dbg('MaskedComboBox::SetValue(%s)' % value, indent=1) if not self._mask: @@ -378,7 +378,7 @@ class BaseMaskedComboBox( wx.ComboBox, MaskedEditMixin ): ## dbg('adjusted value: "%s"' % value) # Attempt to compensate for fact that calling .SetInsertionPoint() makes the - # selection index -1, even if the resulting set value is in the list. + # selection index -1, even if the resulting set value is in the list. # So, if we are setting a value that's in the list, use index selection instead. if value in self._choices: index = self._choices.index(value) @@ -405,11 +405,11 @@ class BaseMaskedComboBox( wx.ComboBox, MaskedEditMixin ): """ This function redefines the externally accessible :meth:`ComboBox.Refresh` to validate the contents of the masked control as it refreshes. - + .. note:: - + This must be done in the class derived from the base wx control. - + """ self._CheckValid() self._Refresh() @@ -428,11 +428,11 @@ class BaseMaskedComboBox( wx.ComboBox, MaskedEditMixin ): This function redefines the externally accessible :meth:`ComboBox.Cut` to be a smart "erase" of the text in question, so as not to corrupt the masked control. - + .. note:: - + This must be done in the class derived from the base wx control. - + """ if self._mask: self._Cut() # call the mixin's Cut method @@ -445,11 +445,11 @@ class BaseMaskedComboBox( wx.ComboBox, MaskedEditMixin ): This function redefines the externally accessible :meth:`ComboBox.Paste` to be a smart "paste" of the text in question, so as not to corrupt the masked control. - - .. note:: - + + .. note:: + This must be done in the class derived from the base wx control. - + """ if self._mask: self._Paste() # call the mixin's Paste method @@ -516,7 +516,7 @@ class BaseMaskedComboBox( wx.ComboBox, MaskedEditMixin ): def AppendItems( self, choices ): """ - :meth:`~lib.masked.combobox.ComboBox.AppendItems` is handled in terms + :meth:`~lib.masked.combobox.ComboBox.AppendItems` is handled in terms of :meth:`lib.masked.combobox.ComboBox.Append`, to avoid code replication. """ for choice in choices: @@ -526,7 +526,7 @@ class BaseMaskedComboBox( wx.ComboBox, MaskedEditMixin ): def Clear( self ): """ This base control function override is necessary so the derived control - can keep track of any additions to the list of choices, because + can keep track of any additions to the list of choices, because :class:`ComboBox` doesn't have an accessor for the choice list. """ if self._mask: @@ -600,9 +600,9 @@ class BaseMaskedComboBox( wx.ComboBox, MaskedEditMixin ): """ Necessary override for bookkeeping on choice selection, to keep current value current. - + :param integer `index`: index to choice item to be set - + """ ## dbg('MaskedComboBox::SetSelection(%d)' % index, indent=1) if self._mask: @@ -813,7 +813,7 @@ __i = 0 ## Version 1.4 ## 1. Added handler for EVT_COMBOBOX to address apparently inconsistent behavior ## of control when the dropdown control is used to do a selection. -## NOTE: due to misbehavior of wx.ComboBox re: losing all concept of the +## NOTE: due to misbehavior of wx.ComboBox re: losing all concept of the ## current selection index if SetInsertionPoint() is called, which is required ## to support masked .SetValue(), this control is flaky about retaining selection ## information. I can't truly fix this without major changes to the base control, diff --git a/wx/lib/masked/ipaddrctrl.py b/wx/lib/masked/ipaddrctrl.py index 50a917e2..14e6c0fa 100644 --- a/wx/lib/masked/ipaddrctrl.py +++ b/wx/lib/masked/ipaddrctrl.py @@ -105,7 +105,7 @@ class IpAddrCtrl( BaseMaskedTextCtrl, IpAddrCtrlAccessorsMixin ): :param string `name`: the window name; :param boolean `setupEventHandling`: setup event handling by default. - """ + """ if 'mask' not in kwargs: kwargs['mask'] = mask = "###.###.###.###" @@ -183,9 +183,9 @@ class IpAddrCtrl( BaseMaskedTextCtrl, IpAddrCtrlAccessorsMixin ): splits it into an array of 4 fields, justifies it appropriately, and inserts it into the control. Invalid values will raise a ValueError exception. - + :param string `value`: the IP address in the form '000.000.000.000' - + """ ## dbg('IpAddrCtrl::SetValue(%s)' % str(value), indent=1) if not isinstance(value, six.string_types): diff --git a/wx/lib/masked/numctrl.py b/wx/lib/masked/numctrl.py index d3367028..f352409a 100644 --- a/wx/lib/masked/numctrl.py +++ b/wx/lib/masked/numctrl.py @@ -3,7 +3,7 @@ # Author: Will Sadkin # Created: 09/06/2003 # Copyright: (c) 2003-2007 by Will Sadkin -# +# # License: wxWidgets license # Tags: phoenix-port, py3-port, unittest, documented #---------------------------------------------------------------------------- @@ -117,7 +117,7 @@ masked.NumCtrl: allowNone Boolean indicating whether or not the control is allowed to be empty, representing a value of None for the control. - + allowNegative Boolean indicating whether or not control is allowed to hold negative numbers. @@ -325,7 +325,7 @@ SetLimitOnFieldChange() out-of-bounds values, but will prevent field change if attempted via navigation, and if the control loses focus, it will change the value to the nearest bound. - + GetLimitOnFieldChange() IsLimitedOnFieldChange() @@ -533,8 +533,8 @@ class NumCtrl(BaseMaskedTextCtrl, NumCtrlAccessorsMixin): its own validation; :param string `name`: the window name; - """ - + """ + ## dbg('masked.NumCtrl::__init__', indent=1) # Set defaults for control: @@ -884,7 +884,7 @@ class NumCtrl(BaseMaskedTextCtrl, NumCtrlAccessorsMixin): ## dbg('old_groupchar: "%s" newgroupchar: "%s"' % (old_groupchar, self._groupChar)) if 'decimalChar' in kwargs and self._decimalChar != old_decimalchar and text.find(old_decimalchar) != -1: text = old_numvalue - + if text != self._GetValue(): if self._decimalChar != '.': # ensure latest decimal char is in "numeric value" so it won't be removed @@ -1068,7 +1068,7 @@ class NumCtrl(BaseMaskedTextCtrl, NumCtrlAccessorsMixin): # and/or just leaving the sign character or changing the sign, # so we can do appropriate things to the value of the control, # we can't just immediately test to see if the value is valid - # If all of these special cases are not in play, THEN we can do + # If all of these special cases are not in play, THEN we can do # a limits check and see if the value is otherwise ok... ## dbg('self._isNeg?', self._isNeg) @@ -1076,7 +1076,7 @@ class NumCtrl(BaseMaskedTextCtrl, NumCtrlAccessorsMixin): ## dbg('just a negative sign; old value < 0; setting replacement of 0') replacement = 0 self._isNeg = False - elif int_str[:2] == '-0': + elif int_str[:2] == '-0': if self._oldvalue < 0: ## dbg('-0; setting replacement of 0') replacement = 0 @@ -1247,9 +1247,9 @@ class NumCtrl(BaseMaskedTextCtrl, NumCtrlAccessorsMixin): """ Handles an event indicating that the text control's value has changed, and issue EVT_NUM event. - - .. note:: - + + .. note:: + Using :meth:`TextCtrl.SetValue` to change the control's contents from within a EVT_CHAR handler can cause double text events. So we check for actual changes to the text before passing the events on. @@ -1296,9 +1296,9 @@ class NumCtrl(BaseMaskedTextCtrl, NumCtrlAccessorsMixin): or colored if not limited but the value is out-of-bounds. A ValueError exception will be raised if an invalid value is specified. - + :param integer `value`: new value - + """ ## dbg('NumCtrl::SetValue(%s)' % value, indent=1) BaseMaskedTextCtrl.SetValue( self, self._toGUI(value) ) @@ -1312,11 +1312,11 @@ class NumCtrl(BaseMaskedTextCtrl, NumCtrlAccessorsMixin): or colored if not limited but the value is out-of-bounds. A ValueError exception will be raised if an invalid value is specified. - + This method does not fire a change event. - + :param integer `value`: new value - + """ ## dbg('NumCtrl::ChangeValue(%s)' % value, indent=1) BaseMaskedTextCtrl.ChangeValue( self, self._toGUI(value) ) @@ -1326,9 +1326,9 @@ class NumCtrl(BaseMaskedTextCtrl, NumCtrlAccessorsMixin): def SetIntegerWidth(self, value): """ Set the integer width of the control - + :param integer `value`: the width value - + """ self.SetParameters(integerWidth=value) @@ -1341,9 +1341,9 @@ class NumCtrl(BaseMaskedTextCtrl, NumCtrlAccessorsMixin): def SetFractionWidth(self, value): """ Set the fraction width of the control - + :param integer `value`: the width value - + """ self.SetParameters(fractionWidth=value) @@ -1368,10 +1368,10 @@ class NumCtrl(BaseMaskedTextCtrl, NumCtrlAccessorsMixin): If min > the max value allowed by the width of the control, the function will return False, and the min will not be set. - + :param `min`: Minium value for the control :type `min`: integer or None - + """ ## dbg('NumCtrl::SetMin(%s)' % repr(min), indent=1) if( self._max is None @@ -1472,9 +1472,9 @@ class NumCtrl(BaseMaskedTextCtrl, NumCtrlAccessorsMixin): If called with a value of False, this function will disable value limiting, but coloring of out-of-bounds values will still take place if bounds have been set for the control. - + :param boolean `limited`: define value limiting - + """ self.SetParameters(limited = limited) @@ -1525,9 +1525,9 @@ class NumCtrl(BaseMaskedTextCtrl, NumCtrlAccessorsMixin): of the control falls within the current bounds. This function can also be called with a value to see if that value would fall within the current bounds of the given control. - + :param `value`: value to check - + """ ## dbg('IsInBounds(%s)' % repr(value), indent=1) if value is None: @@ -1566,9 +1566,9 @@ class NumCtrl(BaseMaskedTextCtrl, NumCtrlAccessorsMixin): of the control is currently None, and allow_none is False, the value of the control will be set to the minimum value of the control, or 0 if no lower bound is set. - + :param boolean `allow_none`: True if None is allowed - + """ self._allowNone = allow_none if not allow_none and self.GetValue() is None: diff --git a/wx/lib/masked/textctrl.py b/wx/lib/masked/textctrl.py index 53aa5e5a..1c93625e 100644 --- a/wx/lib/masked/textctrl.py +++ b/wx/lib/masked/textctrl.py @@ -44,15 +44,15 @@ class BaseMaskedTextCtrl( wx.TextCtrl, MaskedEditMixin ): can prevent exposure of those optional attributes of their base class that do not make sense for their derivation. Therefore, we define:: - + BaseMaskedTextCtrl(TextCtrl, MaskedEditMixin) and:: - + masked.TextCtrl(BaseMaskedTextCtrl, MaskedEditAccessorsMixin). This allows us to then derive:: - + masked.NumCtrl( BaseMaskedTextCtrl ) and not have to expose all the same accessor functions for the @@ -87,7 +87,7 @@ class BaseMaskedTextCtrl( wx.TextCtrl, MaskedEditMixin ): :param string `name`: the window name; :param boolean `setupEventHandling`: setup event handling by default. - """ + """ if not hasattr(self, 'this'): wx.TextCtrl.__init__(self, parent, id, value='', @@ -203,9 +203,9 @@ class BaseMaskedTextCtrl( wx.TextCtrl, MaskedEditMixin ): This function redefines the externally accessible :meth:`TextCtrl.SetValue` to be a smart "paste" of the text in question, so as not to corrupt the masked control. - + .. note:: - + This must be done in the class derived from the base wx control. """ self.ModifyValue(value, use_change_value=False) @@ -214,9 +214,9 @@ class BaseMaskedTextCtrl( wx.TextCtrl, MaskedEditMixin ): """ Provided to accomodate similar functionality added to base control in wxPython 2.7.1.1. - + :param string `value`: new value for control, this will not fire an event - + """ self.ModifyValue(value, use_change_value=True) @@ -297,12 +297,12 @@ class BaseMaskedTextCtrl( wx.TextCtrl, MaskedEditMixin ): def SetFont(self, *args, **kwargs): """ Set the font, then recalculate control size, if appropriate. - + see :meth:`TextCtrl.SetFont` for valid arguements """ wx.TextCtrl.SetFont(self, *args, **kwargs) if self._autofit: -## dbg('calculated size:', self._CalcSize()) +## dbg('calculated size:', self._CalcSize()) self.SetClientSize(self._CalcSize()) width = self.GetSize().width height = self.GetBestSize().height @@ -335,9 +335,9 @@ class BaseMaskedTextCtrl( wx.TextCtrl, MaskedEditMixin ): """ This function redefines the externally accessible :meth:`TextCtrl.Refresh` to validate the contents of the masked control as it refreshes. - + .. note:: - + This must be done in the class derived from the base wx control. """ ## dbg('MaskedTextCtrl::Refresh', indent=1) @@ -359,11 +359,11 @@ class BaseMaskedTextCtrl( wx.TextCtrl, MaskedEditMixin ): This function redefines the externally accessible :meth:`TextCtrl.Cut` to be a smart "erase" of the text in question, so as not to corrupt the masked control. - + .. note:: - + This must be done in the class derived from the base wx control. - + """ if self._mask: self._Cut() # call the mixin's Cut method @@ -376,11 +376,11 @@ class BaseMaskedTextCtrl( wx.TextCtrl, MaskedEditMixin ): This function redefines the externally accessible :meth:`TextCtrl.Paste` to be a smart "paste" of the text in question, so as not to corrupt the masked control. - - .. note:: - + + .. note:: + This must be done in the class derived from the base wx control. - + """ if self._mask: self._Paste() # call the mixin's Paste method