Ejemplo n.º 1
0
 def __setattr__(self, key, val):
     opt = self._get_option(key)
     if isinstance(opt, Config):
         raise dx.TypeError(
             "Cannot assign a value to group of options `%s.*`" %
             (self._prefix + key))
     opt.set(val)
Ejemplo n.º 2
0
 def set(self, x):
     if self._xtype is not None:
         if not isinstance(x, self._xtype):
             raise dx.TypeError(
                 "Invalid value for option `%s`: expected %s, instead got %s"
                 % (self._name, self._xtype, type(x)))
     self._value = x
     if self._onchange is not None:
         self._onchange(x)
Ejemplo n.º 3
0
 def __init__(self, name, default, doc=None, xtype=None, onchange=None):
     self._name = name
     self._default = default
     self._doc = doc
     self._value = default
     self._xtype = xtype
     self._onchange = onchange
     if xtype and not isinstance(default, xtype):
         raise dx.TypeError("Default value `%r` is not of type %s" %
                            (default, xtype))