Package pyforms :: Package gui :: Package Controls :: Module ControlNumber |
[hide private]
[frames] | no frames]

# Source Code for Module pyforms.gui.Controls.ControlNumber

     1  #!/usr/bin/python
     2  # -*- coding: utf-8 -*-
     3
     4  __author__      = "Ricardo Ribeiro"
     5  __credits__     = ["Ricardo Ribeiro"]
     6  __license__     = "MIT"
     7  __version__     = "0.0"
     8  __maintainer__  = "Ricardo Ribeiro"
     9  __email__       = "ricardojvr@gmail.com"
    10  __status__      = "Development"
    11
    12
    13  import os
    14  import pickle
    15  import pyforms.Utils.tools as tools
    16  from PyQt4 import uic, QtGui
    17  from pyforms.gui.Controls.ControlBase import ControlBase
    18
    19 -class ControlNumber(ControlBase):
    20
    21 -        def __init__(self, label = "", defaultValue = 0, min = 0, max = 100):
    22                  self._min = min
    23                  self._max = max
    24                  ControlBase.__init__(self, label, defaultValue)
    25
    26
    27                  self._label = label
    28                  self._value = defaultValue
    29
    30
    31 -        def initForm(self):
    32                  control_path = tools.getFileInSameDirectory(__file__,"number.ui")
    33                  self._form = uic.loadUi( control_path )
    34                  self.label = self._label
    35                  self.value = self._value
    36                  self.form.spinBox.valueChanged.connect( self.valueChanged )
    37                  self.min = self._min
    38                  self.max = self._max
    39
    40 -        def valueChanged(self, value):
    41                  self._updateSlider = False
    42                  self.value = value
    43                  self._updateSlider = True
    44
    45          ############################################################################
    46          ############ Properties ####################################################
    47          ############################################################################
    48
    49          @property
    50 -        def label(self): return self.form.label.text()
    51
    52          @label.setter
    53 -        def label(self, value):
    54                  self.form.label.setText(value)
    55
    56          @property
    57 -        def value(self):
    58                  self._value = self.form.spinBox.value()
    59                  return self._value
    60
    61          @value.setter
    62 -        def value(self, value):
    63                  ControlBase.value.fset(self,value)
    64                  self.form.spinBox.setValue(int(value))
    65
    66
    67          @property
    68 -        def min(self):
    69                  return self.form.spinBox.minimum()
    70
    71          @min.setter
    72 -        def min(self, value): self.form.spinBox.setMinimum(value)
    73
    74          @property
    75 -        def max(self):
    76                  return self.form.spinBox.maximum()
    77
    78          @max.setter
    79 -        def max(self, value): self.form.spinBox.setMaximum(value)
    80