diff --git a/pytabulator/tabulator.py b/pytabulator/tabulator.py index 6c9fc01..b9b9613 100644 --- a/pytabulator/tabulator.py +++ b/pytabulator/tabulator.py @@ -49,6 +49,22 @@ def update_column(self, col_name: str, **kwargs: Any) -> Self: return self + def set_formatter( + self, + col_name: str, + formatter: str, + formatter_params: dict = None, + **kwargs: Any, + ) -> Self: + return self.update_column( + col_name, + **dict( + formatter=formatter, + formatterParams=formatter_params or dict(), + **kwargs, + ), + ) + def set_options(self, **kwargs) -> Self: pass return self diff --git a/tests/test_tabulator_columns.py b/tests/test_tabulator_columns.py index bb1c1b8..ec7ebc8 100644 --- a/tests/test_tabulator_columns.py +++ b/tests/test_tabulator_columns.py @@ -12,3 +12,6 @@ def test_tabulator_columns(persons): table = table.update_column("Name", editor = True) print(table.columns) + + table = table.set_formatter("Age", "html", hozAlign="center") + print(table.columns)