+ def SetParameters(self, **kwargs):
+ dbg('TimeCtrl::SetParameters(%s)' % repr(kwargs), indent=1)
+ maskededit_kwargs = {}
+ reset_format = False
+
+ if kwargs.has_key('display_seconds'):
+ kwargs['displaySeconds'] = kwargs['display_seconds']
+ del kwargs['display_seconds']
+ if kwargs.has_key('format') and kwargs.has_key('displaySeconds'):
+ del kwargs['displaySeconds'] # always apply format if specified
+
+ # assign keyword args as appropriate:
+ for key, param_value in kwargs.items():
+ if key not in TimeCtrl.valid_ctrl_params.keys():
+ raise AttributeError('invalid keyword argument "%s"' % key)
+
+ if key == 'format':
+ # handle both local or generic 'maskededit' autoformat codes:
+ if param_value == 'HHMMSS' or param_value == 'TIMEHHMMSS':
+ self.__displaySeconds = True
+ self.__fmt24hr = False
+ elif param_value == 'HHMM' or param_value == 'TIMEHHMM':
+ self.__displaySeconds = False
+ self.__fmt24hr = False
+ elif param_value == '24HHMMSS' or param_value == '24HRTIMEHHMMSS':
+ self.__displaySeconds = True
+ self.__fmt24hr = True
+ elif param_value == '24HHMM' or param_value == '24HRTIMEHHMM':
+ self.__displaySeconds = False
+ self.__fmt24hr = True
+ else:
+ raise AttributeError('"%s" is not a valid format' % param_value)
+ reset_format = True
+
+ elif key in ("displaySeconds", "display_seconds") and not kwargs.has_key('format'):
+ self.__displaySeconds = param_value
+ reset_format = True
+
+ elif key == "min": min = param_value
+ elif key == "max": max = param_value
+ elif key == "limited": limited = param_value
+
+ elif key == "useFixedWidthFont":
+ maskededit_kwargs[key] = param_value
+
+ elif key == "oob_color":
+ maskededit_kwargs['invalidBackgroundColor'] = param_value
+
+ if reset_format:
+ if self.__fmt24hr:
+ if self.__displaySeconds: maskededit_kwargs['autoformat'] = '24HRTIMEHHMMSS'
+ else: maskededit_kwargs['autoformat'] = '24HRTIMEHHMM'
+
+ # Set hour field to zero-pad, right-insert, require explicit field change,
+ # select entire field on entry, and require a resultant valid entry
+ # to allow character entry:
+ hourfield = Field(formatcodes='0r<SV', validRegex='0\d|1\d|2[0123]', validRequired=True)
+ else:
+ if self.__displaySeconds: maskededit_kwargs['autoformat'] = 'TIMEHHMMSS'
+ else: maskededit_kwargs['autoformat'] = 'TIMEHHMM'
+
+ # Set hour field to allow spaces (at start), right-insert,
+ # require explicit field change, select entire field on entry,
+ # and require a resultant valid entry to allow character entry:
+ hourfield = Field(formatcodes='_0<rSV', validRegex='0[1-9]| [1-9]|1[012]', validRequired=True)
+ ampmfield = Field(formatcodes='S', emptyInvalid = True, validRequired = True)
+
+ # Field 1 is always a zero-padded right-insert minute field,
+ # similarly configured as above:
+ minutefield = Field(formatcodes='0r<SV', validRegex='[0-5]\d', validRequired=True)
+
+ fields = [ hourfield, minutefield ]
+ if self.__displaySeconds:
+ fields.append(copy.copy(minutefield)) # second field has same constraints as field 1
+
+ if not self.__fmt24hr:
+ fields.append(ampmfield)
+
+ # set fields argument:
+ maskededit_kwargs['fields'] = fields
+
+ # This allows range validation if set
+ maskededit_kwargs['validFunc'] = self.IsInBounds
+
+ # This allows range limits to affect insertion into control or not
+ # dynamically without affecting individual field constraint validation
+ maskededit_kwargs['retainFieldValidation'] = True
+
+ if hasattr(self, 'controlInitialized') and self.controlInitialized:
+ self.SetCtrlParameters(**maskededit_kwargs) # set appropriate parameters
+
+ # Validate initial value and set if appropriate
+ try:
+ self.SetBounds(min, max)
+ self.SetLimited(limited)
+ self.SetValue(value)
+ except:
+ self.SetValue('12:00:00 AM')
+ dbg(indent=0)
+ return {} # no arguments to return
+ else:
+ dbg(indent=0)
+ return maskededit_kwargs
+