class GridView(ScrollableView)

A GridView is a user-defined view structured as a grid of equal-sized cells. Abstract methods are provided for drawing the contents of a cell and detecting mouse clicks in a cell based on their row and column numbers.

Note: Don't confuse this with the Grid class, which is a container for laying out other components in a grid.

The extent of a GridView is managed through the num_rows, num_columns and cell_size properties. The extent property inherited from ScrollableView should not be changed directly.


GridView(num_rows, num_columns, cell_size)
Creates a grid view whose extent initially covers the specified number of rows and columns.


Number of rows in the view's extent.

Number of columns in the view's extent.

The size of each cell. A tuple (width, height).

Color with which to fill the background of a cell before calling draw_cell(), or None for no automatic background fill.

Abstract Methods

draw_cell(canvas, row_number, column_number, cell_rect)
Should draw the specified cell inside the given rectangle.

click_cell(row_number, column_number, event)
Called when a mouse_down event occurs in a cell.


cell_rect(row_number, column_number)
Returns the rectangle corresponding to the cell at the given row and column numbers.

Returns a tuple (row_number, column_number) indicating the cell in which the given point lies.