Exemplo n.º 1
0
    def _updateValidator(self, value):
        """This method sets a validator depending on the data type"""
        val = None
        if value is not None and isinstance(value.wvalue, Quantity):
            val = self.validator()
            if not isinstance(val, PintValidator):
                val = PintValidator(self)
                self.setValidator(val)
            attr = self.getModelObj()
            if attr is not None:
                bottom, top = attr.range
                if bottom != val.bottom:
                    val.setBottom(bottom)
                if top != val.top:
                    val.setTop(top)
            units = value.wvalue.units
            if units != val.units:
                val.setUnits(units)

        # @TODO Other validators can be configured for other types
        #       (e.g. with string lengths, tango names,...)
        else:
            self.setValidator(None)
            self.debug("Validator disabled")
        return val
Exemplo n.º 2
0
    def __init__(self, qt_parent=None, designMode=False):
        Qt.QAbstractSpinBox.__init__(self, qt_parent)

        # Overwrite not to show quality by default
        self._showQuality = False

        lineEdit = TaurusValueLineEdit(designMode=designMode)
        lineEdit.setValidator(PintValidator(self))
        lineEdit.setEnableWheelEvent(True)
        self.setLineEdit(lineEdit)
        self.setAccelerated(True)
Exemplo n.º 3
0
    def _updateValidator(self, attr):
        '''This method sets a validator depending on the data type

        :param attr: TaurusAttribute
        '''
        data_type = attr.getType()
        if data_type in [DataType.Integer, DataType.Float]:
            self._min_range, self._max_range = attr.range
            self._min_alarm, self._max_alarm = attr.alarms
            self._default_unit = attr.wvalue.units
            validator = PintValidator()
            validator.setBottom(self._min_range)
            validator.setTop(self._max_range)
            validator.setUnits(self._default_unit)
            self.setValidator(validator)
        else:
            self.setValidator(None)
Exemplo n.º 4
0
    def _updateValidator(self, attr):
        '''This method sets a validator depending on the data type

        :param attr: TaurusAttribute
        '''
        data_type = attr.getType()
        if data_type in [DataType.Integer, DataType.Float]:
            self._min_range, self._max_range = attr.range
            self._min_alarm, self._max_alarm = attr.alarms
            self._default_unit = attr.wvalue.units
            validator = PintValidator()
            validator.setBottom(self._min_range)
            validator.setTop(self._max_range)
            validator.setUnits(self._default_unit)
            self.setValidator(validator)
        else:
            self.setValidator(None)
Exemplo n.º 5
0
    def _updateValidator(self, value):
        '''This method sets a validator depending on the data type'''
        if isinstance(value.wvalue, Quantity):
            val = self.validator()
            if not isinstance(val, PintValidator):
                val = PintValidator(self)
                self.setValidator(val)
            attr = self.getModelObj()
            bottom, top = attr.range
            if bottom != val.bottom:
                val.setBottom(bottom)
            if top != val.top:
                val.setTop(top)
            units = value.wvalue.units
            if units != val.units:
                val.setUnits(units)

        # @TODO Other validators can be configured for other types (e.g. with string lengths, tango names,...)
        else:
            self.setValidator(None)
            self.debug("Validator disabled")