PEATDB/Tables.py
def findValue(self, searchstring=None, findagain=None):
        """Return the row/col for the input value"""
        if searchstring == None:
            searchstring = tkSimpleDialog.askstring("Search table.",
                                               "Enter search value",
                                               parent=self.parentframe)
        found=0
        if findagain == None or not hasattr(self,'foundlist'):
            self.foundlist=[]
        if self.model!=None:
            for row in range(self.rows):
                for col in range(self.cols):
                    text = str(self.model.getValueAt(row,col))
                    if text=='' or text==None:
                        continue
                    cell=row,col
                    if findagain == 1 and cell in self.foundlist:
                        continue
                    if text.lower().find(searchstring.lower())!=-1:
                        print 'found in',row,col
                        found=1
                        #highlight cell
                        self.delete('searchrect')
                        self.draw_rect(row, col, color='red', tag='searchrect', delete=0)
                        self.lift('searchrect')
                        self.lift('celltext'+str(col)+'_'+str(row))
                        #add row/col to foundlist
                        self.foundlist.append(cell)
                        #need to scroll to centre the cell here..
                        x,y = self.getCanvasPos(row, col)
                        self.xview('moveto', x)
                        self.yview('moveto', y)
                        self.tablecolheader.xview('moveto', x)
                        self.tablerowheader.yview('moveto', y)
                        return row, col
        if found==0:
            self.delete('searchrect')
            print 'nothing found'
            return None
Return the row/col for the input value
Return the row/col for the input value
Return the row / col for the input value
def findValue(self, searchstring=None, findagain=None):
        if searchstring == None:
            searchstring = tkSimpleDialog.askstring("Search table.",
                                               "Enter search value",
                                               parent=self.parentframe)
        found=0
        if findagain == None or not hasattr(self,'foundlist'):
            self.foundlist=[]
        if self.model!=None:
            for row in range(self.rows):
                for col in range(self.cols):
                    text = str(self.model.getValueAt(row,col))
                    if text=='' or text==None:
                        continue
                    cell=row,col
                    if findagain == 1 and cell in self.foundlist:
                        continue
                    if text.lower().find(searchstring.lower())!=-1:
                        print 'found in',row,col
                        found=1
                        self.delete('searchrect')
                        self.draw_rect(row, col, color='red', tag='searchrect', delete=0)
                        self.lift('searchrect')
                        self.lift('celltext'+str(col)+'_'+str(row))
                        self.foundlist.append(cell)
                        x,y = self.getCanvasPos(row, col)
                        self.xview('moveto', x)
                        self.yview('moveto', y)
                        self.tablecolheader.xview('moveto', x)
                        self.tablerowheader.yview('moveto', y)
                        return row, col
        if found==0:
            self.delete('searchrect')
            print 'nothing found'
            return None
def findValue ( self , searchstring = None , findagain = None ) : if searchstring == None : searchstring = tkSimpleDialog . askstring ( "Search table." , "Enter search value" , parent = self . parentframe ) found = 0 if findagain == None or not hasattr ( self , 'foundlist' ) : self . foundlist = [ ] if self . model != None : for row in range ( self . rows ) : for col in range ( self . cols ) : text = str ( self . model . getValueAt ( row , col ) ) if text == '' or text == None : continue cell = row , col if findagain == 1 and cell in self . foundlist : continue if text . lower ( ) . find ( searchstring . lower ( ) ) != - 1 : print 'found in' , row , col found = 1 self . delete ( 'searchrect' ) self . draw_rect ( row , col , color = 'red' , tag = 'searchrect' , delete = 0 ) self . lift ( 'searchrect' ) self . lift ( 'celltext' + str ( col ) + '_' + str ( row ) ) self . foundlist . append ( cell ) x , y = self . getCanvasPos ( row , col ) self . xview ( 'moveto' , x ) self . yview ( 'moveto' , y ) self . tablecolheader . xview ( 'moveto' , x ) self . tablerowheader . yview ( 'moveto' , y ) return row , col if found == 0 : self . delete ( 'searchrect' ) print 'nothing found' return None
Return the row/col for the input value
Return the row / col for the input value
"""Return the row/col for the input value""" #highlight cell #add row/col to foundlist #need to scroll to centre the cell here..
self
searchstring
findagain