Replies: 1 comment
-
One solution is to use modules grid_module.py from shiny import module, ui, render
import pandas as pd
@module.ui
def grid_ui():
return ui.output_data_frame("grid")
@module.server
def grid_server(input, output, session, df: pd.DataFrame):
@render.data_frame
def grid():
return render.DataGrid(
df,
editable=True,
width='fit-content',
summary=True,
filters=False,
selection_mode='none',
) app.py import pandas as pd
from shiny import App, ui, render
from grid_module import grid_ui, grid_server
dummy_df = pd.DataFrame({
"col1": [1, 2, 3],
"col2": [4, 5, 6],
"col3": [7, 8, 9]
})
input_list = ['foo', 'bar', 'lee']
app_ui = ui.page_fillable(
ui.div("hi!"),
ui.output_ui("dynamic_tables")
)
def server(input, output, session):
@render.ui
def dynamic_tables():
return ui.TagList(*[grid_ui(name) for name in input_list])
for name in input_list:
grid_server(name, df=dummy_df)
app = App(app_ui, server) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, thanks for shiny!
I'm an advanced user in shiny for R but very new to shiny for python.
Problem
I have a list of inputs and I want to generate a table (DataGrid) for each of them.
Reprex (vibe coded)
This is my best attempt, and it does not work.
Question
How should I do that with python? In R, I think we could create some dynamic observers inside the server code. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions