PEATDB/Tables.py
def draw_Text(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
        # If celltxt is a number then we make it a string
        import types
        if type(celltxt) is types.FloatType or type(celltxt) is types.IntType:
            celltxt=str(celltxt)
        #if cell width is less than x, print nothing
        if w<=15:
            return

        fontsize = self.fontsize
        scale = fontsize*1.2
        total = len(celltxt)
        
        if len(celltxt) > w/scale:           
            celltxt=celltxt[0:int(w/fontsize*1.2)-3]
        if len(celltxt) < total:
            celltxt=celltxt+'..'            
        if w < 25:
            celltxt = ''
        if fgcolor == None or fgcolor == "None":
            fgcolor = 'black'
        if align == None:
            align = 'center'
        elif align == 'w':
            x1 = x1-w/2+1

        #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.split(' ')
                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
Draw the text inside a cell area
Draw the text inside a cell area
Draw the text inside a cell area
def draw_Text(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
        import types
        if type(celltxt) is types.FloatType or type(celltxt) is types.IntType:
            celltxt=str(celltxt)
        if w<=15:
            return
        fontsize = self.fontsize
        scale = fontsize*1.2
        total = len(celltxt)
        if len(celltxt) > w/scale:           
            celltxt=celltxt[0:int(w/fontsize*1.2)-3]
        if len(celltxt) < total:
            celltxt=celltxt+'..'            
        if w < 25:
            celltxt = ''
        if fgcolor == None or fgcolor == "None":
            fgcolor = 'black'
        if align == None:
            align = 'center'
        elif align == 'w':
            x1 = x1-w/2+1
        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)
        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 draw_Text ( 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 import types if type ( celltxt ) is types . FloatType or type ( celltxt ) is types . IntType : celltxt = str ( celltxt ) if w <= 15 : return fontsize = self . fontsize scale = fontsize * 1.2 total = len ( celltxt ) if len ( celltxt ) > w / scale : celltxt = celltxt [ 0 : int ( w / fontsize * 1.2 ) - 3 ] if len ( celltxt ) < total : celltxt = celltxt + '..' if w < 25 : celltxt = '' if fgcolor == None or fgcolor == "None" : fgcolor = 'black' if align == None : align = 'center' elif align == 'w' : x1 = x1 - w / 2 + 1 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 ) 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
Draw the text inside a cell area
Draw the text inside a cell area
"""Draw the text inside a cell area""" # If celltxt is a number then we make it a string #if cell width is less than x, print nothing #if celltxt is dict then we are drawing a hyperlink  #f,s = self.thefont.split(' ') #just normal text        
self
row
col
celltxt
fgcolor
align