Ejemplo n.º 1
0
    def label(self, value):
        """
        Convert a value into its representing label

        The value is converted to a plain text using
        `QLocale().toString(value)`.
        This method is often overloaded by applications to have individual
        labels.
        
        :param float value: Value
        :return: Label string
        """
        return QLocale().toString(value)
Ejemplo n.º 2
0
 def maxLabelHeight(self, font):
     """
     :param QFont font: Font
     :return: the maximum height of a label
     """
     ticks = self.scaleDiv().ticks(QwtScaleDiv.MajorTick)
     if not ticks:
         return 0
     if self.labelAutoSize():
         vmax = sorted([v for v in ticks if self.scaleDiv().contains(v)],
                        key=lambda obj: len(QLocale().toString(obj)))[-1]
         return np.ceil(self.labelSize(font, vmax).height())
         ## Original implementation (closer to Qwt's C++ code, but slower):
         #return np.ceil(max([self.labelSize(font, v).height()
         #                for v in ticks if self.scaleDiv().contains(v)]))
     else:
         return self._get_max_label_size(font).height()
Ejemplo n.º 3
0
 def label(self, value):
     return QLocale().toString(value)