예제 #1
0
 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)
예제 #2
0
 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__)
예제 #3
0
 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__)
예제 #4
0
 def GetPhilValue(self):
     self.Validate()
     val_str = ValidatedTextCtrl.GetValue(self)
     if (val_str == ""):
         return self.ReturnNoneIfOptional()
     return val_str
예제 #5
0
 def __init__ (self, *args, **kwds) :
   ValidatedTextCtrl.__init__(self, *args, **kwds)
예제 #6
0
 def Enable (self, enable=True) :
   ValidatedTextCtrl.Enable(self, enable)
   if (self._spinner is not None) :
     self._spinner.Enable(enable)
예제 #7
0
 def SetValue(self, value):
     if (value is None):
         ValidatedTextCtrl.SetValue(self, "")
     else:
         assert isinstance(value, list), value
         ValidatedTextCtrl.SetValue(self, self.FormatValue(value))
예제 #8
0
 def __init__(self, *args, **kwds):
     ValidatedTextCtrl.__init__(self, *args, **kwds)