Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
Expand Down Expand Up @@ -50,7 +49,7 @@ jobs:
# =====================================================
- uses: quarto-dev/quarto-actions/setup@v2
with:
version: 1.4.549
version: 1.4.557

- name: Build site
run: |
Expand Down
3 changes: 3 additions & 0 deletions _quarto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ website:
image-height: 630
card-style: "summary_large_image"

repo-url: https://github.com/posit-dev/py-shiny-site
repo-actions: [issue, edit]

navbar:
background: primary
foreground: light
Expand Down
1 change: 1 addition & 0 deletions components/_metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ filters:
- quarto
- line-highlight
- shinylive
repo-actions: false
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def penguins_df():

@render.ui
def rows():
rows = penguins_df.input_cell_selection()["rows"] # <<
rows = penguins_df.cell_selection()["rows"] # <<
selected = ", ".join(str(i) for i in sorted(rows)) if rows else "None"
return f"Rows selected: {selected}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@render.ui()
def rows():
rows = penguins_df.input_cell_selection()["rows"] # <<
rows = penguins_df.cell_selection()["rows"] # <<
selected = ", ".join(str(i) for i in sorted(rows)) if rows else "None"
return f"Rows selected: {selected}"

Expand Down
6 changes: 3 additions & 3 deletions components/outputs/data-grid/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ listing:
- title: Select Rows
description: Set `selection_mode` in `render.DataGrid()` to `"row"` to allow the
user to select one row at a time. Set it to `"rows"` to allow the user to select
multiple rows at a time. Access the selection(s) as `<id>.input_cell_selection()["rows"]`.
multiple rows at a time. Access the selection(s) as `<id>.cell_selection()["rows"]`.
apps:
- title: Preview
file: app-variation-select-rows-core.py
Expand Down Expand Up @@ -130,9 +130,9 @@ To make a reactive Data Grid, follow three steps:

A Data Grid can also collect input from the user. To allow this, set `render.DataGrid(selection_mode="row")` or `render.DataGrid(selection_mode="rows")` to allow the user to select one or more rows of the Data Grid.

The indices of the selected rows will be accessible within the server function as a reactive variable returned by `<name>.input_cell_selection()["rows"]`, where <name> is the name of the function decorated with `@render.data_frame`.
The indices of the selected rows will be accessible within the server function as a reactive variable returned by `<name>.cell_selection()["rows"]`, where <name> is the name of the function decorated with `@render.data_frame`.

The value returned will be an empty tuple if no rows are selected, or a tuple of integers representing the indices of the selected rows. To filter a pandas data frame down to the selected rows, use `df.iloc[list(<name>.input_cell_selection()["rows"])]`.
The value returned will be an empty tuple if no rows are selected, or a tuple of integers representing the indices of the selected rows. To filter a pandas data frame down to the selected rows, use `df.iloc[list(<name>.cell_selection()["rows"])]`.

For more information about interacting with data frames, see the API documentation for [Express](../../../api/express/express.render.data_frame.qmd) or [Core](../../../api/core/render.data_frame.qmd) syntax.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def penguins_df():

@render.ui
def rows():
rows = penguins_df.input_cell_selection()["rows"] # <<
rows = penguins_df.cell_selection()["rows"] # <<
selected = ", ".join(str(i) for i in sorted(rows)) if rows else "None"
return f"Rows selected: {selected}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@render.ui
def rows():
rows = penguins_df.input_cell_selection()["rows"] # <<
rows = penguins_df.cell_selection()["rows"] # <<
selected = ", ".join(str(i) for i in sorted(rows)) if rows else "None"
return f"Rows selected: {selected}"

Expand Down
6 changes: 3 additions & 3 deletions components/outputs/datatable/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ listing:
- title: Select Rows
description: Set `selection_mode` in `render.DataTable()` to `"row"` to allow
the user to select one row at a time. Set it to `"rows"` to allow the user to
select multiple rows at a time. Access the selection(s) as `<id>.input_cell_selection()["rows"]`.
select multiple rows at a time. Access the selection(s) as `<id>.cell_selection()["rows"]`.
apps:
- title: Preview
file: app-variation-select-rows-core.py
Expand Down Expand Up @@ -130,9 +130,9 @@ To make a reactive Data Table, follow three steps:

A Data Table can also collect input from the user. To allow this, set `render.DataTable(selection_mode="row")` or `render.DataTable(selection_mode="rows")` to allow the user to select one or more rows of the Data Table.

The indices of the selected rows will be accessible within the server function as a reactive variable returned by `<name>.input_cell_selection()["rows"]`, where <name> is the name of the function decorated with `@render.data_frame`.
The indices of the selected rows will be accessible within the server function as a reactive variable returned by `<name>.cell_selection()["rows"]`, where <name> is the name of the function decorated with `@render.data_frame`.

The value returned will be an empty tuple if no rows are selected, or a tuple of integers representing the indices of the selected rows. To filter a pandas data frame down to the selected rows, use `df.iloc[list(<name>.input_cell_selection()["rows"])]`.
The value returned will be an empty tuple if no rows are selected, or a tuple of integers representing the indices of the selected rows. To filter a pandas data frame down to the selected rows, use `df.iloc[list(<name>.cell_selection()["rows"])]`.

For more information about interacting with data frames, see the API documentation for [Express](../../../api/express/express.render.data_frame.qmd) or [Core](../../../api/core/render.data_frame.qmd) syntax.

Expand Down
74 changes: 44 additions & 30 deletions docs/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,43 +207,57 @@ def shinylive_app_preview(


def express_core_preview(
app_express: str | None = None,
app_core: str | None = None,
files: list[str] | str | None = None,
div_attrs=".shiny-mode-tabset",
group="shiny-app-mode",
language="py",
**kwargs,
app_express: str,
app_core: str,
div_attrs: str = '.shiny-mode-tabset group="shiny-app-mode"',
) -> None:
if app_express is None and app_core is None:
return

if files is None:
files = []
elif isinstance(files, str):
files = [files]
app_preview_code(
{
"Express": app_express,
"Core": app_core,
},
div_attrs=div_attrs,
)

header_attrs = ".panel-tabset"
header_attrs += " " + div_attrs if div_attrs else ""
header_attrs += f" group='{group}'" if group else ""

block = QuartoPrint(["::: {" + header_attrs + "}"])
def app_preview_code(
app_files: str | dict[str, str],
files: list[str] | str | None = None,
language: Literal["auto", "py", "r"] = "auto",
div_attrs: str = "",
) -> None:

apps = zip([app_express, app_core], ["Express", "Core"])
is_tabset = isinstance(app_files, dict)

for app_file, tab_name in apps:
if app_file is None:
continue
if is_tabset:
div_attrs = ".panel-tabset " + div_attrs

sl_app = ShinyliveApp.from_local(app_file, files, language)
lang = "python" if language == "py" else "r"
block = QuartoPrint(["::: {" + div_attrs + "}"])

block.append("### " + tab_name)
block.append(
f'```{{.{lang} .code-overflow-scroll shinylive="{sl_app.to_url()}"}}'
)
block.append_file(app_file)
block.extend(["```", ""])
if not is_tabset:
_add_code_chunk(block, app_files, files, language)
else:
for x in app_files:
block.append(f"## {x}")
_add_code_chunk(block, app_files[x], files, language)

block.append(":::")
print(block)


def _add_code_chunk(
block: QuartoPrint,
file: str,
files: list[str] | str | None = None,
language: Literal["auto", "py", "r"] = "auto",
):
if language == "auto":
language = "py" if file.endswith(".py") else "r"

sl_app = ShinyliveApp.from_local(file, files=files, language=language)

lang = "python" if language == "py" else "r"

block.append(f'```{{.{lang} .code-overflow-scroll shinylive="{sl_app.to_url()}"}}')
block.append_file(file)
block.append("```")
2 changes: 1 addition & 1 deletion docs/overview.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ shiny create -t dashboard
## Development workflow

See the [workflow](install-create-run.qmd) section for more information developing Shiny apps locally.
Also keep in mind you can develop apps in the browser using the [playground](/playground).
Also keep in mind you can develop apps in the browser using the [playground](https://shinylive.io/py/examples/).
:::


Expand Down
4 changes: 2 additions & 2 deletions docs/user-interfaces.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ With Shiny, you can create a wide variety of user interfaces (UI), including das
Here, we'll use the following dashboard as motivation to learn about some important UI components (e.g., [cards](#cards), [value boxes](#value-boxes)) and layouts (e.g., [columns](#multi-column-layout)).


![A Shiny dashboard with visuals for exploring restaurant tips (see [here](#altogether-now) for the code).](assets/tipping-dashboard.png){class="img-shadow"}
![A Shiny dashboard with visuals for exploring restaurant tips (see [here](#all-together-now) for the code).](assets/tipping-dashboard.png){class="img-shadow"}

::: callout-tip
## More UI design inspiration
Expand Down Expand Up @@ -207,7 +207,7 @@ Did you know the app viewer above is resizable? Try resizing it to see how the l

Tooltips and popovers are a useful means for both displaying and interacting with additional information in a non-obtrusive way.
Tooltips are shown on hover, whereas popovers are shown on click, making them more suitable for interactive content like inputs.
In the [actual dashboard](#altogether-now), we'll leverage a popover to effectively add a toolbar with additional inputs controls to card headers.
In the [actual dashboard](#all-together-now), we'll leverage a popover to effectively add a toolbar with additional inputs controls to card headers.

```{shinylive-python}
#| standalone: true
Expand Down
1 change: 1 addition & 0 deletions gallery/_metadata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
repo-actions: false
1 change: 1 addition & 0 deletions index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ format:
smooth-scroll: true
css:
- index.css
repo-actions: false
---

::::{.column-screen .mx-auto .pt-0 .mt-0 .pt-xl-5 style="max-width: 1500px;"}
Expand Down
7 changes: 4 additions & 3 deletions layouts/_metadata.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sidebar: layouts
format:
html:
css:
css:
- /components/_partials/components.css
- _partials/layouts-list.css
toc: false
Expand All @@ -10,5 +10,6 @@ format:
filters:
- quarto
- line-highlight
- shinylive

- shinylive

repo-actions: false
2 changes: 1 addition & 1 deletion py-shiny
Submodule py-shiny updated 639 files
7 changes: 4 additions & 3 deletions templates/_metadata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ format:
html:
template: _partials/gallery-article.template
page-layout: article
css:
css:
- /components/_partials/components.css
- _partials/templates.css
toc: false
code-line-numbers: false
include-after-body: ../components/_partials/componentsjs.html
filters:
- shinylive

- shinylive

repo-actions: false