Skip to content

Commit

Permalink
Add generic set_formatter func
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Kuethe committed Sep 21, 2024
1 parent 39ed0d1 commit ad8e4e6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pytabulator/tabulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions tests/test_tabulator_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit ad8e4e6

Please sign in to comment.