示例#1
0
 def toNative(self):
     'Return the Native Units'
     try:
         val = float(self.text())
     except ValueError:
         val = 0
     conv = conversion(self._quantity, self._units)
     
     return conv[0](val)
示例#2
0
    def displayText(self, value, locale):
        _units = read_setting("%s_units" % self._quantity)

        if _units is None:
            _units = self._default

        _abbr = abbr(self._quantity, _units)
        _conv = conversion(self._quantity, _units)

        if _units is None or _abbr is None or _conv[1] is None:
            return "%.1f" % value
        elif self._showAbbr:
            return "%.1f %s" % (_conv[1](value), _abbr)
        else:
            return "%.1f" % _conv[1](value)
示例#3
0
 def fromNative(self, val):
     'Set the value from the Native Units'
     conv = conversion(self._quantity, self._units)
     self.setText('%.3g' % conv[1](val))