Logo Search packages:      
Sourcecode: hamster-applet version File versions

def hamster::charting::Chart::_ellipsize_text (   self,
  context,
  text,
  width 
) [private]

try to constrain text into pixels by ellipsizing end
   TODO - check if cairo maybe has ability to ellipsize automatically

Definition at line 498 of file charting.py.

00498                                                     :
        """try to constrain text into pixels by ellipsizing end
           TODO - check if cairo maybe has ability to ellipsize automatically
        """
        extent = context.text_extents(text) #x, y, width, height
        if extent[2] <= width:
            return text
        
        res = text
        while res:
            res = res[:-1]
            extent = context.text_extents(res + "…") #x, y, width, height
            if extent[2] <= width:
                return res + "…"
        
        return text # if can't fit - return what we have
        
    def _horizontal_bar_chart(self, context):


Generated by  Doxygen 1.6.0   Back to index