def __init__(self, subhead='subhead', image_=None, **args): Table.__init__(self, width='100%', class_='mainheader', colspan=0, **args) atts = {'class' : 'mainheader'} self.h1 = Header('hello there', 1) self.h2 = Header(subhead, 2) toprow = TableRow(**atts) if image_ is None: image_ = Image() self._image = image_ toprow.append(TableCell(image_, align='left', **atts)) toprow.append(TableCell(self.h1, align='center', **atts)) self.append(toprow) self.append(TableRow(TableCell(self.h2, colspan=3, align='center', **atts), **atts))
class MainTable(Table): def __init__(self, page, **args): class_atts = dict(class_='maintable') headfoot_atts = dict(colspan=2) headfoot_atts.update(class_atts) Table.__init__(self, width='100%', **class_atts) self._header = MainHeader('hello') self._footer = MainFooter('hello') self._headcell = TableCell(self._header, **headfoot_atts) self._footcell = TableCell(self._footer, **headfoot_atts) headrow = TableRow(self._headcell, **class_atts) self.append(headrow) self._mainrow = TableRow(**class_atts) self._mainmenu = MainMenu(width='100%') self._mainmenu_cell = TableCell(self._mainmenu, rowspan=1, colspan=1, valign='top', **class_atts) self._mainrow.append(self._mainmenu_cell) self._mainpage = TableCell(page, width='75%', align='center', **class_atts) self._mainrow.append(self._mainpage) self.append(self._mainrow) footrow = TableRow(self._footcell, **class_atts) self.append(footrow) def update_mainpage_attributes(self, **atts): self._mainpage.attributes.update(atts) def set_page_data(self, page): self._mainpage.set(page) def append_page_data(self, item): self._mainpage.append(item) def clear_page_data(self): self._mainpage.clear() def set_header(self, data): self._header.set_h1(data) def set_header_image(self, **atts): self._header.set_image(**atts) def set_subhead(self, data): self._header.set_h2(data) def set_footer(self, data): self._footer.set_subhead(data) def set_mainrow(self, data, tablecell=False): if not tablecell: self._mainrow.set(data) else: raise IndexError, "not an index error, passing tablecell is unimplemented now" def reset_mainrow(self): self._mainrow.set(self._mainmenu_cell) self._mainrow.append(self._mainpage) def set_menu_entries(self, entries, header=None): self._mainmenu.set_new_entries(entries, header) def reset_menu_entries(self): self._mainmenu.reset_entries()
def _make_labelentry(self, info, input): row = TableRow() row.append(TableCell(info)) row.append(TableCell(input)) return row