(self, row, col, celltxt, fgcolor=None, align=None)
return
Draw the text inside a cell area
Draw the text inside a cell area
Draw the text inside a cell area
def drawText(self, row, col, celltxt, fgcolor=None, align=None):
        """Draw the text inside a cell area"""

        self.delete('celltext'+str(col)+'_'+str(row))
        h=self.rowheight
        x1,y1,x2,y2 = self.getCellCoords(row,col)
        w=x2-x1
        wrap = False
        pad=5
        # If celltxt is a number then we make it a string
        if type(celltxt) is float or type(celltxt) is int:
            celltxt=str(celltxt)
        length = len(celltxt)
        if length == 0:
            return
        #if cell width is less than x, print nothing
        if w<=10:
            return

        if fgcolor == None or fgcolor == "None":
            fgcolor = self.fgcolor
        if align == None:
            align = 'w'
        if align == 'w':
            x1 = x1-w/2+pad
        elif align == 'e':
            x1 = x1+w/2-pad

        if w < 18:
            celltxt = '.'
        else:
            fontsize = self.fontsize
            colname = self.model.getColumnName(col)
            #scaling between canvas and text normalised to about font 14
            scale = 8.5 * float(fontsize)/12
            size = length * scale
            if size > w:
                newlength = w / scale
                #print w, size, length, newlength
                celltxt = celltxt[0:int(math.floor(newlength))]

        #if celltxt is dict then we are drawing a hyperlink
        if self.isLink(celltxt) == True:
            haslink=0
            linktext=celltxt['text']
            if len(linktext) > w/scale or w<28:
                linktext=linktext[0:int(w/fontsize*1.2)-2]+'..'
            if celltxt['link']!=None and celltxt['link']!='':
                f,s = self.thefont
                linkfont = (f, s, 'underline')
                linkcolor='blue'
                haslink=1
            else:
                linkfont = self.thefont
                linkcolor=fgcolor

            rect = self.create_text(x1+w/2,y1+h/2,
                                      text=linktext,
                                      fill=linkcolor,
                                      font=linkfont,
                                      tag=('text','hlink','celltext'+str(col)+'_'+str(row)))
            if haslink == 1:
                self.tag_bind(rect, '<Double-Button-1>', self.check_hyperlink)

        #just normal text
        else:
            rect = self.create_text(x1+w/2,y1+h/2,
                                      text=celltxt,
                                      fill=fgcolor,
                                      font=self.thefont,
                                      anchor=align,
                                      tag=('text','celltext'+str(col)+'_'+str(row)))
        return
def drawText ( self , row , col , celltxt , fgcolor = None , align = None ) : self . delete ( 'celltext' + str ( col ) + '_' + str ( row ) ) h = self . rowheight x1 , y1 , x2 , y2 = self . getCellCoords ( row , col ) w = x2 - x1 wrap = False pad = 5 # If celltxt is a number then we make it a string if type ( celltxt ) is float or type ( celltxt ) is int : celltxt = str ( celltxt ) length = len ( celltxt ) if length == 0 : return #if cell width is less than x, print nothing if w <= 10 : return if fgcolor == None or fgcolor == "None" : fgcolor = self . fgcolor if align == None : align = 'w' if align == 'w' : x1 = x1 - w / 2 + pad elif align == 'e' : x1 = x1 + w / 2 - pad if w < 18 : celltxt = '.' else : fontsize = self . fontsize colname = self . model . getColumnName ( col ) #scaling between canvas and text normalised to about font 14 scale = 8.5 * float ( fontsize ) / 12 size = length * scale if size > w : newlength = w / scale #print w, size, length, newlength celltxt = celltxt [ 0 : int ( math . floor ( newlength ) ) ] #if celltxt is dict then we are drawing a hyperlink if self . isLink ( celltxt ) == True : haslink = 0 linktext = celltxt [ 'text' ] if len ( linktext ) > w / scale or w < 28 : linktext = linktext [ 0 : int ( w / fontsize * 1.2 ) - 2 ] + '..' if celltxt [ 'link' ] != None and celltxt [ 'link' ] != '' : f , s = self . thefont linkfont = ( f , s , 'underline' ) linkcolor = 'blue' haslink = 1 else : linkfont = self . thefont linkcolor = fgcolor rect = self . create_text ( x1 + w / 2 , y1 + h / 2 , text = linktext , fill = linkcolor , font = linkfont , tag = ( 'text' , 'hlink' , 'celltext' + str ( col ) + '_' + str ( row ) ) ) if haslink == 1 : self . tag_bind ( rect , '<Double-Button-1>' , self . check_hyperlink ) #just normal text else : rect = self . create_text ( x1 + w / 2 , y1 + h / 2 , text = celltxt , fill = fgcolor , font = self . thefont , anchor = align , tag = ( 'text' , 'celltext' + str ( col ) + '_' + str ( row ) ) ) return