#NEWLINE# def setColor( self , color ) : #NEWLINE# #INDENT# exists = False #NEWLINE# for c in self . _colorHistory : #NEWLINE# #INDENT# if ( color == c ) : #NEWLINE# #INDENT# exists = True #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# if ( not exists ) : #NEWLINE# #INDENT# self . _colorHistory . append ( color ) #NEWLINE# #UNINDENT# colorList = list ( self . _colorHistory ) #NEWLINE# colorList . reverse ( ) #NEWLINE# colorList . insert ( 0 , colorList . pop ( colorList . index ( color ) ) ) #NEWLINE# colors = [ ( [ None ] * self . _columns ) for _ in range ( self . _rows ) ] #NEWLINE# iterator = iter ( colorList ) #NEWLINE# for row in range ( self . _rows ) : #NEWLINE# #INDENT# for col in range ( self . _columns ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# colors [ row ] [ col ] = iterator . next ( ) #NEWLINE# #UNINDENT# except StopIteration : #NEWLINE# #INDENT# colors [ row ] [ col ] = Color . WHITE #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . _grid . setColorGrid ( colors ) #NEWLINE# self . _grid . requestRepaint ( )