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
:add
add_anchor
add_centered
anchor
attention_lost
augment_mouse_event
bg_color
bg_image
border_color
border_width
call_handler
call_parent_handler
cell_rect
click_item
defer_drawing
dismiss
draw
draw_item_and_highlight
draw_over
draw_posthighlight
draw_prehighlight
fg_color
focus
focus_switch
font
get_cursor
get_focus
get_margin_rect
get_root
get_top_widget
get_visible
global_to_local
has_focus
highlight_style
inherited
invalidate
is_gl_container
item_is_selected
key_down
key_up
local_to_global
margin
menu_bar
num_cols
num_rows
parent
parent_resized
present
rect
relative_mode
remove
remove_anchor
resized
scale_bg
scroll_button_color
scroll_button_size
sel_color
sel_width
set_parent
set_size_for_text
tab_stop
visible