Module albow.table.TableRowBase

Source code
from pygame import Rect

from albow.containers.PaletteView import PaletteView


class TableRowBase(PaletteView):

    def __init__(self, cell_size, nrows, scrolling, **kwds):
        """

        :param cell_size:
        :param nrows:
        :param scrolling:
        """
        #
        # Python 3 update
        #
        # PaletteView.__init__(self, cell_size, nrows, 1, scrolling=scrolling)
        super().__init__(cell_size, nrows, 1, scrolling=scrolling, **kwds)

    def num_items(self):
        return self.parent.num_rows()

    def draw_item(self, surf, row, row_rect):
        table = self.parent
        height = row_rect.height
        row_data = self.row_data(row)
        for i, x, width, column, cell_data in table.column_info(row_data):
            cell_rect = Rect(x, row_rect.top, width, height)
            self.draw_table_cell(surf, cell_data, cell_rect, column)

    def row_data(self, row):
        return self.parent.row_data(row)

    def draw_table_cell(self, surf, data, cell_rect, column):
        self.parent.draw_table_cell(surf, data, cell_rect, column)

Classes

class TableRowBase (cell_size, nrows, scrolling, **kwds)

The PaletteView class is an abstract base class for implementing tool palettes and similar things. A PaletteView displays an array of items which can be selected by clicking, with the selected item being highlighted. There is provision for scrolling, so that the palette can contain more items than are displayed at one time.

The PaletteView does not maintain the items themselves or keep track of which one is selected; these things are responsibilities of the subclass.

:param cell_size: :param nrows: :param scrolling:

Source code
class TableRowBase(PaletteView):

    def __init__(self, cell_size, nrows, scrolling, **kwds):
        """

        :param cell_size:
        :param nrows:
        :param scrolling:
        """
        #
        # Python 3 update
        #
        # PaletteView.__init__(self, cell_size, nrows, 1, scrolling=scrolling)
        super().__init__(cell_size, nrows, 1, scrolling=scrolling, **kwds)

    def num_items(self):
        return self.parent.num_rows()

    def draw_item(self, surf, row, row_rect):
        table = self.parent
        height = row_rect.height
        row_data = self.row_data(row)
        for i, x, width, column, cell_data in table.column_info(row_data):
            cell_rect = Rect(x, row_rect.top, width, height)
            self.draw_table_cell(surf, cell_data, cell_rect, column)

    def row_data(self, row):
        return self.parent.row_data(row)

    def draw_table_cell(self, surf, data, cell_rect, column):
        self.parent.draw_table_cell(surf, data, cell_rect, column)

Ancestors

Subclasses

Methods

def draw_item(self, surf, row, row_rect)
Source code
def draw_item(self, surf, row, row_rect):
    table = self.parent
    height = row_rect.height
    row_data = self.row_data(row)
    for i, x, width, column, cell_data in table.column_info(row_data):
        cell_rect = Rect(x, row_rect.top, width, height)
        self.draw_table_cell(surf, cell_data, cell_rect, column)
def draw_table_cell(self, surf, data, cell_rect, column)
Source code
def draw_table_cell(self, surf, data, cell_rect, column):
    self.parent.draw_table_cell(surf, data, cell_rect, column)
def num_items(self)
Source code
def num_items(self):
    return self.parent.num_rows()
def row_data(self, row)
Source code
def row_data(self, row):
    return self.parent.row_data(row)

Inherited members