(self, tokensource)
Create drawables for the token content.
Create drawables for the token content.
Create drawables for the token content .
def _create_drawables(self, tokensource):
        """
        Create drawables for the token content.
        """
        lineno = charno = maxcharno = 0
        for ttype, value in tokensource:
            while ttype not in self.styles:
                ttype = ttype.parent
            style = self.styles[ttype]
            # TODO: make sure tab expansion happens earlier in the chain.  It
            # really ought to be done on the input, as to do it right here is
            # quite complex.
            value = value.expandtabs(4)
            lines = value.splitlines(True)
            #print lines
            for i, line in enumerate(lines):
                temp = line.rstrip('\n')
                if temp:
                    self._draw_text(
                        self._get_text_pos(charno, lineno),
                        temp,
                        font = self._get_style_font(style),
                        fill = self._get_text_color(style)
                    )
                    charno += len(temp)
                    maxcharno = max(maxcharno, charno)
                if line.endswith('\n'):
                    # add a line for each extra line in the value
                    charno = 0
                    lineno += 1
        self.maxcharno = maxcharno
        self.maxlineno = lineno
def _create_drawables ( self , tokensource ) : lineno = charno = maxcharno = 0 for ttype , value in tokensource : while ttype not in self . styles : ttype = ttype . parent style = self . styles [ ttype ] # TODO: make sure tab expansion happens earlier in the chain.  It # really ought to be done on the input, as to do it right here is # quite complex. value = value . expandtabs ( 4 ) lines = value . splitlines ( True ) #print lines for i , line in enumerate ( lines ) : temp = line . rstrip ( '\n' ) if temp : self . _draw_text ( self . _get_text_pos ( charno , lineno ) , temp , font = self . _get_style_font ( style ) , fill = self . _get_text_color ( style ) ) charno += len ( temp ) maxcharno = max ( maxcharno , charno ) if line . endswith ( '\n' ) : # add a line for each extra line in the value charno = 0 lineno += 1 self . maxcharno = maxcharno self . maxlineno = lineno