Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

improvement: make table download actions configurable (#2710)

Myles Scolnick7ce08b6b9306
diff --git a/marimo/_plugins/ui/_impl/table.py b/marimo/_plugins/ui/_impl/table.py
index b90c9bccd3..a54443b7d1 100644
--- a/marimo/_plugins/ui/_impl/table.py
+++ b/marimo/_plugins/ui/_impl/table.py
@@ -193,6 +193,8 @@ class table(UIElement[List[str], Union[List[JSONType], IntoDataFrame]]):
defaults to 10
- `show_column_summaries`: whether to show column summaries
defaults to `True` when the table has less than 40 columns, `False` otherwise
+ - `show_download`: whether to show the download button
+ defaults to `True` for dataframes, `False` otherwise
- `format_mapping`: a mapping from column names to formatting strings
or functions
- `freeze_columns_left`: list of column names to freeze on the left
@@ -220,6 +222,7 @@ class table(UIElement[List[str], Union[List[JSONType], IntoDataFrame]]):
] = None,
freeze_columns_left: Optional[Sequence[str]] = None,
freeze_columns_right: Optional[Sequence[str]] = None,
+ show_download: bool = True,
*,
label: str = "",
on_change: Optional[
@@ -345,7 +348,8 @@ class table(UIElement[List[str], Union[List[JSONType], IntoDataFrame]]):
selection if self._manager.supports_selection() else None
),
"show-filters": self._manager.supports_filters(),
- "show-download": self._manager.supports_download(),
+ "show-download": show_download
+ and self._manager.supports_download(),
"show-column-summaries": show_column_summaries,
"row-headers": self._manager.get_row_headers(),
"freeze-columns-left": freeze_columns_left,
diff --git a/tests/_plugins/ui/_impl/test_table.py b/tests/_plugins/ui/_impl/test_table.py
index df4a6cc80e..c823dc5266 100644
--- a/tests/_plugins/ui/_impl/test_table.py
+++ b/tests/_plugins/ui/_impl/test_table.py
@@ -556,3 +556,20 @@ def test_show_column_summaries_disabled():
assert summaries.is_disabled is False
assert summaries.data is None
assert len(summaries.summaries) == 0
+
+
+ not DependencyManager.pandas.has(), reason="Pandas not installed"
+)
+def test_show_download():
+ import pandas as pd
+
+ data = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
+ table_default = ui.table(data)
+ assert table_default._component_args["show-download"] is True
+
+ table_true = ui.table(data, show_download=True)
+ assert table_true._component_args["show-download"] is True
+
+ table_false = ui.table(data, show_download=False)
+ assert table_false._component_args["show-download"] is False