Package pyforms :: Package web :: Package Controls :: Module ControlSlider |
[hide private]
[frames] | no frames]

# Source Code for Module pyforms.web.Controls.ControlSlider

     1  from pyforms.web.Controls.ControlBase import ControlBase
     2
     3
     4 -class ControlSlider(ControlBase):
     5
     6      _min = 0
     7      _max = 100
     8
     9 -    def __init__(self, label = "", defaultValue = 0, min = 0, max = 100):
    10          self._updateSlider = True
    11          self._min = min
    12          self._max = max
    13
    14          ControlBase.__init__(self, label, defaultValue)
    15
    16 -    def initControl(self):
    17          values = self._label, self._name, self._value, self._min, self._max , self.help
    18          return "controls.push(new ControlSlider('%s', '%s', %d, %d, %d,'%s'));" % values
    19
    20 -    def valueChanged(self, value):
    21          self._updateSlider = False
    22          self.value = value
    23          self._updateSlider = True
    24
    25 -    def load(self, data):
    26          if 'value' in data: self.value = data['value']
    27
    28 -    def changed(self): pass
    29
    30 -    def save(self, data):
    31          if self.value: data['value'] = self.value
    32
    33      @property
    34 -    def value(self): return self._value
    35
    36      @value.setter
    37 -    def value(self, value):
    38          if isinstance(value, int): ControlBase.value.fset(self, value)
    39          else: ControlBase.value.fset(self, value['position'])
    40
    41
    42      @property
    43 -    def min(self): return self._min
    44
    45      @min.setter
    46 -    def min(self, value):  self._min = value
    47
    48      @property
    49 -    def max(self):  return  self._max
    50
    51      @max.setter
    52 -    def max(self, value):  self._max = value
    53