class table_view.TableView(Widget)A TableView
provides a tabular view of data having a fixed number of columns and a
variable number of rows. There may be a header providing titles for the
columns. There is provision for scrolling and for allowing the user to
An auxiliary class TableColumn is used to configure the formatting of the headers and data.
By default, all headers and data are displayed textually, but this can be changed by overriding methods of the TableView.
- TableView(nrows = None, height = None, header_height = None, row_height = None, scrolling = True)
The TableView is initialized with a width and height determined as follows:
- The initial width is calculated from the information in the columns attribute.
- The initial height, excluding the header, is determined either directly by the height parameter or by the row height and number of rows nrows. If no row_height is specified, it is calculated from the size of the font.
- The height of the header is determined by header_height, or the size of the header font.
If scrolling is true, the table will display scrolling arrows.
- A list of TableColumn instances describing the columns of the table.
- Font in which to display the column headers.
- Foreground colour of the column headers.
- Background colour of the column headers, or None.
- Space to leave between the header and the rows.
- Space to leave either side of the contents of a column.
- Should return the number of rows in the table. Must be implemented.
- Should return a sequence of data items for row number n. The data items may be of any type, provided they can be formatted as specified by the corresponding TableColumn. Must be implemented.
- Should return true if row number n is to be considered selected. The default implementation always returns false.
- Called when row number n is clicked. The default implementation does nothing.
- draw_header_cell(surface, colnum, rect, coldesc)
- Draws the header of column number colnum. The rect is the rectangle corresponding to the header area, and coldesc is the TableColumn instance describing the column. By default, the column's title is displayed using the header_font and the alignment specified by coldesc.
draw_table_cell(surface, colnum, data, rect, coldesc)
- Draws a cell of the table. The colnum is the column number, data is the data item to be displayed, rect is the rectangle corresponding to the cell, and coldesc is the TableColumn instance describing the column. By default, the data is formatted as specified by coldesc and rendered using the widget's font.