API Documentation
Basic usage
import pandas as pd
from pytabulator import TableOptions, render_data_frame
from shiny import render
from shiny.express import input, ui
ui.div("Click on row to print name", style="padding: 10px;")
@render.code
async def txt():
print(input.tabulator_row_clicked())
return input.tabulator_row_clicked()["Name"]
@render_data_frame(table_options=TableOptions(height=500))
def tabulator():
return pd.read_csv(
"https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.csv"
)
See also detailed example.
pytabulator.shiny_bindings
render_data_frame
Bases: Renderer[DataFrame]
A decorator for a function that returns a DataFrame
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table_options |
TableOptions
|
Table options. |
{}
|
Source code in pytabulator/shiny_bindings.py
render_tabulator
Bases: Renderer[Tabulator]
A decorator for a function that returns a Tabulator
table
Source code in pytabulator/shiny_bindings.py
output_tabulator(id)
Create an output container for a Tabulator
table
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id |
str
|
An output id of a |
required |
Source code in pytabulator/shiny_bindings.py
pytabulator.utils
create_columns(df, default_filter=False, default_editor=False, updates={})
Create columns configuration from a data frame
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df |
DataFrame
|
The data frame to create columns from. |
required |
default_filter |
bool
|
Whether to add a default header filter to each column. |
False
|
default_editor |
bool
|
Whether to add a default editor to each column. |
False
|
updates |
dict
|
Dictionary of updates that overwrite the default settings or add additional settings the columns. |
{}
|
Source code in pytabulator/utils.py
pytabulator.tabulator
Tabulator
Bases: object
Tabulator
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df |
DataFrame
|
A data frame. |
required |
table_options |
TableOptions
|
Table options. |
{}
|
Source code in pytabulator/tabulator.py
pytabulator.tabulator_context
TabulatorContext
Bases: object
Table context
Source code in pytabulator/tabulator_context.py
add_call(method_name, *args)
Add a method call that is executed on the table instance
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method_name |
str
|
The name of the method to be executed. |
required |
*args |
any
|
The arguments to be passed to the table method. |
()
|
Source code in pytabulator/tabulator_context.py
add_row(row={})
delete_row(index)
Delete a row from the table
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index |
int | str
|
The index of the row to delete. |
required |
delete_selected_rows()
redo()
trigger_download(type='csv', file_name=None, *args)
Trigger download
Parameters:
Name | Type | Description | Default |
---|---|---|---|
type |
str
|
The data type of the file to be downloaded. |
'csv'
|
file_name |
str
|
The file name. |
None
|
*args |
any
|
The arguments to be passed to the |
()
|
Source code in pytabulator/tabulator_context.py
trigger_get_data()
pytabulator.TableOptions
dataclass
Bases: TableOptions
Table options
Attributes:
Name | Type | Description |
---|---|---|
add_row_pos |
Literal['bottom', 'top']
|
Where to add rows. Defaults to |
columns |
list
|
Column definitions. |
frozen_rows |
int
|
Number of frozen rows. Defaults to |
group_by |
Union[str, list]
|
Columns to group by. Defaults to |
header_visible |
bool
|
Whether to display the header of the table. Defaults to |
height |
Union[int, None]
|
The height of the table in pixels. Defaults to |
history |
bool
|
Whether to enable history. Must be set if |
index |
str
|
The field to be used as a unique index for each row. Defaults to |
layout |
Literal['fitData', 'fitDataFill', 'fitDataStretch', 'fitDataTable', 'fitColumns']
|
The layout of the table. Defaults to |
movable_rows |
bool
|
Whether rows are movable. Defaults to |
pagination_add_row |
Literal['page', 'table']
|
Where to add rows when pagination is enabled. Defaults to |
pagination |
bool
|
Whether to enable pagination. Defaults to |
pagination_counter |
str
|
Whether to display counted rows in footer. Defaults to |
resizable_column_fit |
bool
|
Maintain total column width when resizing a column. Defaults to |
row_height |
int
|
Fixed height for rows. Defaults to |
selectable_rows |
Union[str, bool, int]
|
Whether a row is selectable. An integer value sets the maximum number of rows, that can be selected.
If set to |