class grid_view.GridView(Widget)

The GridView class is an abstract base class for widgets that display information in a regular grid of rows and columns. Subclasses implement methods that define the size of the grid, for drawing a cell of the grid and for responding to mouse clicks in a cell.

Constructor

GridView(cell_size, nrows, ncols)
Initializes the grid view with the specified cell_size, and a rect sized to show nrows rows and ncols columns of cells.

Note that nrows and ncols are used only for calculating the initial size of the widget, and are not stored.

Attributes

cell_size
A tuple defining the size of one grid cell.

Methods

cell_rect(row, col)
Returns a rectangle covering the cell for row row and column col.

Abstract Methods

num_rows()
Should return the current number of rows in the grid.

num_cols()
Should return the current number of columns in the grid.

draw_cell(surface, row, col, rect)
Should draw the cell at row row and column col inside the specified rectangle.

click_cell(row, col, event)
Called when a mouse-down event occurs in the cell at row row and column col. The event passed has a cell_local attribute containing the coordinates relative to the top left of the cell. This is only called for clicks within the currently valid range of cells, as determined by num_rows() and num_cols().
---