def SetValue(self, value): if (value in [None, Auto]): ValidatedTextCtrl.SetValue(self, "") else : if isinstance(value, str): if wxtbx.is_unicode_build(): ValidatedTextCtrl.SetValue(self, to_unicode(value)) else : ValidatedTextCtrl.SetValue(self, value) else : if (not isinstance(value, unicode)): raise RuntimeError("Improper value (type: %s) for control %s" % (type(value).__name__, self.GetName())) ValidatedTextCtrl.SetValue(self, value)
def SetSymop(self, value): if type(value) == type(u'abc'): value = value.encode("ascii", "ignore") if (value is None) or (value is Auto): ValidatedTextCtrl.SetValue(self, "") elif (isinstance(value, str)): try: from cctbx import sgtbx rt_mx = sgtbx.rt_mx(symbol=value) except ValueError: raise Sorry("Inappropriate value '%s' for %s." % (value, self.GetName())) else: ValidatedTextCtrl.SetValue(self, str(value)) else: raise TypeError("Type '%s' not allowed!" % type(value).__name__)
def SetFloat(self, value): if (value is None) or (value is Auto): ValidatedTextCtrl.SetValue(self, "") elif (isinstance(value, float) or isinstance(value, int)): ValidatedTextCtrl.SetValue(self, str(value)) elif (isinstance(value, str)): try : # TODO remove this after testing value = float(value) except ValueError : raise Sorry("Inappropriate value '%s' for %s." % (value, self.GetName())) else : ValidatedTextCtrl.SetValue(self, str(value)) else : raise TypeError("Type '%s' not allowed!" % type(value).__name__)
def GetPhilValue(self): self.Validate() val_str = ValidatedTextCtrl.GetValue(self) if (val_str == ""): return self.ReturnNoneIfOptional() return val_str
def __init__ (self, *args, **kwds) : ValidatedTextCtrl.__init__(self, *args, **kwds)
def Enable (self, enable=True) : ValidatedTextCtrl.Enable(self, enable) if (self._spinner is not None) : self._spinner.Enable(enable)
def SetValue(self, value): if (value is None): ValidatedTextCtrl.SetValue(self, "") else: assert isinstance(value, list), value ValidatedTextCtrl.SetValue(self, self.FormatValue(value))
def __init__(self, *args, **kwds): ValidatedTextCtrl.__init__(self, *args, **kwds)