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

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

     1  from pyforms.terminal.Controls.ControlBase import ControlBase
     2
     3 -class ControlSlider(ControlBase):
     4
     5      _min = 0
     6      _max = 100
     7
     8 -    def __init__(self, label = "", helptext=None, defaultValue = 0, min = 0, max = 100):
     9          self._updateSlider = True
    10          self._min = min
    11          self._max = max
    12
    13          ControlBase.__init__(self, label, defaultValue)
    14
    15 -    def initControl(self):
    16          #return """<label for="id%s">%s</label>
    17          #                <div class='slider' name='%s' id='id%s' ></div>
    18          #               <script>
    19          #                    $(function() {$( "#id%s" ).slider({change: UpdateSlider, min:%d, max:%d,  value: %d });});
    20          #               </script>
    21          #               """ % ( self._name,  self._label, self._name, self._name, self._name, self._min, self._max, self._value)
    22          return "controls.push(new ControlSlider('%s', '%s', %d, %d, %d));" % ( self._label, self._name, self._value, self._min, self._max )
    23
    24 -    def valueChanged(self, value):
    25          self._updateSlider = False
    26          self.value = value
    27          self._updateSlider = True
    28
    29 -    def load(self, data):
    30          if 'value' in data: self.value = data['value']
    31
    32 -    def changed(self): pass
    33
    34 -    def save(self, data):
    35          if self.value: data['value'] = self.value
    36
    37      @property
    38 -    def value(self): return self._value
    39
    40      @value.setter
    41 -    def value(self, value): self._value = value
    42
    43
    44      @property
    45 -    def min(self): return self._min
    46
    47      @min.setter
    48 -    def min(self, value):  self._min = value
    49
    50      @property
    51 -    def max(self):  return  self._max
    52
    53      @max.setter
    54 -    def max(self, value):  self._max = value
    55