diff --git a/docs/examples/getting_started/app.py b/docs/examples/getting_started/app.py index ecd7287..0d0c268 100644 --- a/docs/examples/getting_started/app.py +++ b/docs/examples/getting_started/app.py @@ -25,6 +25,7 @@ def tabulator(): .set_options(height=311) .set_column_formatter_star("Pclass", 3) .set_column_formatter_tick_cross("Survived", hozAlign="center") + .set_column_editor("Fare", "number", dict(min=0, max=10)) ) @render.code diff --git a/pytabulator/tabulator.py b/pytabulator/tabulator.py index 45691a2..2e6165d 100644 --- a/pytabulator/tabulator.py +++ b/pytabulator/tabulator.py @@ -65,19 +65,26 @@ def set_column_formatter( ), ) - def set_column_formatter_star(self, column: str, stars: int, **kwargs) -> Self: + def set_column_formatter_star(self, col_name: str, stars: int, **kwargs) -> Self: formatter_params = dict(stars=stars) self.set_column_formatter( - column, "star", formatter_params, hozAlign="center", **kwargs + col_name, "star", formatter_params, hozAlign="center", **kwargs ) return self - def set_column_formatter_tick_cross(self, column, **kwargs) -> Self: - self.set_column_formatter(column, "tickCross", **kwargs) + def set_column_formatter_tick_cross(self, col_name, **kwargs) -> Self: + self.set_column_formatter(col_name, "tickCross", **kwargs) return self - def set_column_editor(self) -> Self: - return self + def set_column_editor(self, col_name: str, editor: str, editor_params: dict = None, **kwargs: Any) -> Self: + return self.update_column( + col_name, + **dict( + editor=editor, + editorParams=editor_params or dict(), + **kwargs, + ), + ) def set_options(self, **kwargs) -> Self: self._options = self._options.model_copy(update = kwargs)