def test_pop_cell(self): table = TempyTable(data=self.data) # test pop last r = table.pop_cell() self.assertEqual(r, self.data[-1][-1]) # test pop get tags r = table.pop_cell(tags=True) test_cell = Td()(self.data[-2][-1]) self.assertEqual(r, test_cell) # test pop by index row r = table.pop_cell(0) self.assertEqual(r, self.data[0][-1]) # test pop by index row andcol r = table.pop_cell(0, 0) self.assertEqual(r, self.data[0][0])
from tempy.widgets import TempyTable from tempy.tags import * from tempy.elements import Css data = [['Name', 'Last Name', 'Age', 'Telephone'], ['John', 'Doe', '34', '555666777', '444555333'], ['Michael', 'Roberts', '22', '555766777', '244555333']] special_cell = Td()(A(href='python.org'), P()('first paragraph', P()('nested paragraph'))) table1 = TempyTable(rows=3, cols=4, data=data, head=True, caption='User information', width='100%') table2 = TempyTable(data=data, caption='User information2', width='50%', border='1px solid black') table3 = TempyTable(data=data, caption='User information3', width='50%') table4 = TempyTable(data=data, caption='User information4', width='50%') table2.pop_cell() special_cell.append_to(table2.childs[0].childs[2]) css_tag = Css({ '.class_example_1': {'color': 'blue'}, '.class_example_2': {'color': 'pink'}, '.class_example_3': {'background-color': 'grey'}, }) # set class for every cell table1.col_class('class_example_2') # applies function to upper string for every cell table1.map_col(lambda x: x.upper()) # set class for first column of each row