#NEWLINE# def __init__( self , portrayal_method , grid_height , grid_width , canvas_height = 500 , canvas_width = 500 ) : #NEWLINE# #INDENT# '\n        Instantiate a new CanvasGrid.\n\n        Args:\n            portrayal_method: function to convert each object on the grid to\n                              a portrayal, as described above.\n            grid_height, grid_width: Size of the grid, in cells.\n            canvas_height, canvas_width: Size of the canvas to draw in the\n                                         client, in pixels. (default: 500x500)\n        ' #NEWLINE# self . portrayal_method = portrayal_method #NEWLINE# self . grid_height = grid_height #NEWLINE# self . grid_width = grid_width #NEWLINE# self . canvas_height = canvas_height #NEWLINE# self . canvas_width = canvas_width #NEWLINE# new_element = 'new CanvasModule({}, {}, {}, {})' . format ( self . canvas_width , self . canvas_height , self . grid_width , self . grid_height ) #NEWLINE# self . js_code = ( ( 'elements.push(' + new_element ) + ');' )