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
PaletteView:addadd_anchoradd_centeredanchorattention_lostaugment_mouse_eventbg_colorbg_imageborder_colorborder_widthcall_handlercall_parent_handlercell_rectclick_itemdefer_drawingdismissdrawdraw_item_and_highlightdraw_overdraw_posthighlightdraw_prehighlightfg_colorfocusfocus_switchfontget_cursorget_focusget_margin_rectget_rootget_top_widgetget_visibleglobal_to_localhas_focushighlight_styleinheritedinvalidateis_gl_containeritem_is_selectedkey_downkey_uplocal_to_globalmarginmenu_barnum_colsnum_rowsparentparent_resizedpresentrectrelative_moderemoveremove_anchorresizedscale_bgscroll_button_colorscroll_button_sizesel_colorsel_widthset_parentset_size_for_texttab_stopvisible