PEATDB/Tables.py
def redrawTable(self, event=None, callback=None):
        """Draw the table from scratch based on it's model data"""
        import time
        model = self.model
        self.rows=self.model.getRowCount()
        self.cols=self.model.getColumnCount()
        self.tablewidth=(self.cellwidth)*self.cols
        self.configure(bg=self.cellbackgr)
        #determine col positions for first time
        self.set_colPositions()
        
        #are we drawing a filtered subset of the recs?
        if self.filtered == True and self.model.filteredrecs != None:            
            self.rows = len(self.model.filteredrecs)
            self.delete('colrect')
            
        #check if large no. of records and switch to paging view
        if self.paging == 0 and self.rows >= 500:
            self.paging = 1
        #if using paging, we only want to display the current page..
        if self.paging == 1:
            self.numpages = int(math.ceil(float(self.rows)/self.rowsperpage))
          
            if self.currentpage == None:
                self.currentpage = 0
            self.drawNavFrame()
        else:
            try:
                self.navFrame.destroy()
                self.navFrame.forget()
            except:
                pass
        #determine current range of rows to draw if paging
        if self.paging == 1 and self.rows>self.rowsperpage:
            lower=self.currentpage*self.rowsperpage
            upper=lower+self.rowsperpage
            if upper>=self.rows:
                upper=self.rows
            self.rowrange=range(lower,upper)
            self.configure(scrollregion=(0,0, self.tablewidth+self.x_start, self.rowheight*self.rowsperpage+10))
        else:
            self.rowrange = range(0,self.rows)
            self.configure(scrollregion=(0,0, self.tablewidth+self.x_start, self.rowheight*self.rows+10))
            
        self.draw_grid()
        self.update_idletasks()
        self.tablecolheader.redraw()
        self.tablerowheader.redraw(paging=self.paging)
        align=None
        self.delete('fillrect')
     
        if self.cols == 0 or self.rows == 0:
            self.delete('entry')
            self.delete('rowrect')
            self.delete('currentrect')
            return

        #now draw model data in cells
        rowpos=0
        if self.model!=None:
            for row in self.rowrange:
                if callback != None:
                    callback()                   
                for col in range(self.cols):
                    colname = model.getColumnName(col)
                    if colname == 'name' or colname == 'Name':
                        align='w'
                    else:
                        align=None
                    bgcolor = self.model.getColorAt(row,col, 'bg')
                    fgcolor = self.model.getColorAt(row,col, 'fg')
                    text = self.model.getValueAt(row,col)
                    self.draw_Text(rowpos, col, text, fgcolor, align)
                    if bgcolor != None:
                        self.draw_rect(rowpos,col, color=bgcolor)
                rowpos+=1
        self.setSelectedRow(0)
        self.drawSelectedRow()
        self.draw_selected_rect(self.currentrow, self.currentcol)
        if len(self.multiplerowlist)>1:
            self.drawMultipleRows(self.multiplerowlist)

        return
Draw the table from scratch based on it's model data
Draw the table from scratch based on it's model data
Draw the table from scratch based on it ' s model data
def redrawTable(self, event=None, callback=None):
        import time
        model = self.model
        self.rows=self.model.getRowCount()
        self.cols=self.model.getColumnCount()
        self.tablewidth=(self.cellwidth)*self.cols
        self.configure(bg=self.cellbackgr)
        self.set_colPositions()
        if self.filtered == True and self.model.filteredrecs != None:            
            self.rows = len(self.model.filteredrecs)
            self.delete('colrect')
        if self.paging == 0 and self.rows >= 500:
            self.paging = 1
        if self.paging == 1:
            self.numpages = int(math.ceil(float(self.rows)/self.rowsperpage))
            if self.currentpage == None:
                self.currentpage = 0
            self.drawNavFrame()
        else:
            try:
                self.navFrame.destroy()
                self.navFrame.forget()
            except:
                pass
        if self.paging == 1 and self.rows>self.rowsperpage:
            lower=self.currentpage*self.rowsperpage
            upper=lower+self.rowsperpage
            if upper>=self.rows:
                upper=self.rows
            self.rowrange=range(lower,upper)
            self.configure(scrollregion=(0,0, self.tablewidth+self.x_start, self.rowheight*self.rowsperpage+10))
        else:
            self.rowrange = range(0,self.rows)
            self.configure(scrollregion=(0,0, self.tablewidth+self.x_start, self.rowheight*self.rows+10))
        self.draw_grid()
        self.update_idletasks()
        self.tablecolheader.redraw()
        self.tablerowheader.redraw(paging=self.paging)
        align=None
        self.delete('fillrect')
        if self.cols == 0 or self.rows == 0:
            self.delete('entry')
            self.delete('rowrect')
            self.delete('currentrect')
            return
        rowpos=0
        if self.model!=None:
            for row in self.rowrange:
                if callback != None:
                    callback()                   
                for col in range(self.cols):
                    colname = model.getColumnName(col)
                    if colname == 'name' or colname == 'Name':
                        align='w'
                    else:
                        align=None
                    bgcolor = self.model.getColorAt(row,col, 'bg')
                    fgcolor = self.model.getColorAt(row,col, 'fg')
                    text = self.model.getValueAt(row,col)
                    self.draw_Text(rowpos, col, text, fgcolor, align)
                    if bgcolor != None:
                        self.draw_rect(rowpos,col, color=bgcolor)
                rowpos+=1
        self.setSelectedRow(0)
        self.drawSelectedRow()
        self.draw_selected_rect(self.currentrow, self.currentcol)
        if len(self.multiplerowlist)>1:
            self.drawMultipleRows(self.multiplerowlist)
        return
def redrawTable ( self , event = None , callback = None ) : import time model = self . model self . rows = self . model . getRowCount ( ) self . cols = self . model . getColumnCount ( ) self . tablewidth = ( self . cellwidth ) * self . cols self . configure ( bg = self . cellbackgr ) self . set_colPositions ( ) if self . filtered == True and self . model . filteredrecs != None : self . rows = len ( self . model . filteredrecs ) self . delete ( 'colrect' ) if self . paging == 0 and self . rows >= 500 : self . paging = 1 if self . paging == 1 : self . numpages = int ( math . ceil ( float ( self . rows ) / self . rowsperpage ) ) if self . currentpage == None : self . currentpage = 0 self . drawNavFrame ( ) else : try : self . navFrame . destroy ( ) self . navFrame . forget ( ) except : pass if self . paging == 1 and self . rows > self . rowsperpage : lower = self . currentpage * self . rowsperpage upper = lower + self . rowsperpage if upper >= self . rows : upper = self . rows self . rowrange = range ( lower , upper ) self . configure ( scrollregion = ( 0 , 0 , self . tablewidth + self . x_start , self . rowheight * self . rowsperpage + 10 ) ) else : self . rowrange = range ( 0 , self . rows ) self . configure ( scrollregion = ( 0 , 0 , self . tablewidth + self . x_start , self . rowheight * self . rows + 10 ) ) self . draw_grid ( ) self . update_idletasks ( ) self . tablecolheader . redraw ( ) self . tablerowheader . redraw ( paging = self . paging ) align = None self . delete ( 'fillrect' ) if self . cols == 0 or self . rows == 0 : self . delete ( 'entry' ) self . delete ( 'rowrect' ) self . delete ( 'currentrect' ) return rowpos = 0 if self . model != None : for row in self . rowrange : if callback != None : callback ( ) for col in range ( self . cols ) : colname = model . getColumnName ( col ) if colname == 'name' or colname == 'Name' : align = 'w' else : align = None bgcolor = self . model . getColorAt ( row , col , 'bg' ) fgcolor = self . model . getColorAt ( row , col , 'fg' ) text = self . model . getValueAt ( row , col ) self . draw_Text ( rowpos , col , text , fgcolor , align ) if bgcolor != None : self . draw_rect ( rowpos , col , color = bgcolor ) rowpos += 1 self . setSelectedRow ( 0 ) self . drawSelectedRow ( ) self . draw_selected_rect ( self . currentrow , self . currentcol ) if len ( self . multiplerowlist ) > 1 : self . drawMultipleRows ( self . multiplerowlist ) return
Draw the table from scratch based on it's model data
Draw the table from scratch based on it ' s model data
"""Draw the table from scratch based on it's model data""" #determine col positions for first time #are we drawing a filtered subset of the recs? #check if large no. of records and switch to paging view #if using paging, we only want to display the current page.. #determine current range of rows to draw if paging #now draw model data in cells
self
event
callback