def test_col_class(self): table = TempyTable(data=self.data) table.col_class('class_example') self.assertEqual({'class_example'}, table.childs[0].childs[0].childs[0].attrs['klass']) # first column of each row table.col_class('class_example_new', 0) self.assertEqual({'class_example_new', 'class_example'}, table.childs[0].childs[0].childs[0].attrs['klass'])
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 table2.col_class('class_example_1', 0) # applies function to lower string for second column table2.map_col(lambda x: x.lower(), 1) # applies function to upper string for last column table2.map_col(lambda x: x.upper(), 4) # set class for every row table3.row_class('class_example_3')