Beispiel #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)
Beispiel #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__)
Beispiel #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__)
Beispiel #4
0
 def SetValue(self, value):
     if (value is None):
         ValidatedTextCtrl.SetValue(self, "")
     else:
         assert isinstance(value, list), value
         ValidatedTextCtrl.SetValue(self, self.FormatValue(value))