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
5 changes: 4 additions & 1 deletion docs/dashboards/_examples/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# This file generated by Quarto; do not edit by hand.
# shiny_mode: core

from __future__ import annotations

Expand All @@ -14,7 +15,7 @@ def server(input: Inputs, output: Outputs, session: Session) -> None:

# ========================================================================

from shiny import render, ui
from shiny.express import render, ui
ui.input_select("x", "Variable:",
choices=["bill_length_mm", "bill_depth_mm"])
ui.input_select("dist", "Distribution:", choices=["hist", "kde"])
Expand All @@ -32,6 +33,8 @@ def displot():



return None


_static_assets = ["shiny-python-simple_files"]
_static_assets = {"/" + sa: Path(__file__).parent / sa for sa in _static_assets}
Expand Down
52 changes: 40 additions & 12 deletions docs/dashboards/_examples/inputs/app.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,71 @@
# This file generated by Quarto; do not edit by hand.
# shiny_mode: core

from __future__ import annotations

from pathlib import Path
from shiny import App, Inputs, Outputs, Session, ui

import seaborn as sns
penguins = sns.load_dataset("penguins")
species = list(penguins["species"].value_counts().index)
islands = list(penguins["island"].value_counts().index)

# ========================================================================




def server(input: Inputs, output: Outputs, session: Session) -> None:
from shiny import ui, render
import seaborn as sns
penguins = sns.load_dataset("penguins")
from shiny import reactive
from shiny.express import render, ui
ui.input_checkbox_group(
"species", "Species:",
species, selected = species
)

# ========================================================================

ui.input_checkbox_group(
"islands", "Islands:",
islands, selected = islands
)

# ========================================================================

ui.input_select("x", "Variable:",
choices=["bill_length_mm", "bill_depth_mm"])
ui.input_select("dist", "Distribution:", choices=["hist", "kde"])
ui.input_select("dist", "Distribution:", choices=["kde", "hist"])
ui.input_checkbox("rug", "Show rug marks", value = False)

# ========================================================================

@reactive.calc
def filtered_penguins():
data = penguins[penguins["species"].isin(input.species())]
data = data[data["island"].isin(input.islands())]
return data

# ========================================================================

@render.plot
def displot():
sns.displot(
data=penguins, hue="species", multiple="stack",
x=input.x(), rug=input.rug(), kind=input.dist())
def depth():
return sns.displot(
filtered_penguins(), x = "bill_depth_mm",
hue = "species", kind = input.dist(),
fill = True, rug=input.rug()
)

# ========================================================================



return None


_static_assets = ["toolbar_files"]
_static_assets = ["column-layout_files"]
_static_assets = {"/" + sa: Path(__file__).parent / sa for sa in _static_assets}

app = App(
Path(__file__).parent / "toolbar.html",
Path(__file__).parent / "column-layout.html",
server,
static_assets=_static_assets,
)
2 changes: 1 addition & 1 deletion docs/dashboards/_examples/inputs/card-toolbar.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ penguins = sns.load_dataset("penguins")

```{python}
#| content: card-sidebar
from shiny import ui, render
from shiny.express import ui, render
ui.input_select("x", "Variable:",
choices=["bill_length_mm", "bill_depth_mm"])
ui.input_select("dist", "Distribution:", choices=["hist", "kde"])
Expand Down
3 changes: 2 additions & 1 deletion docs/dashboards/_examples/inputs/column-layout.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ islands = list(penguins["island"].value_counts().index)
::: {.inputs header-for="next" layout-ncol="3"}

```{python}
from shiny import render, reactive, ui
from shiny import reactive
from shiny.express import render, ui
ui.input_checkbox_group(
"species", "Species:",
species, selected = species
Expand Down
2 changes: 1 addition & 1 deletion docs/dashboards/_examples/inputs/inline-sidebar.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ penguins = sns.load_dataset("penguins")
### {.sidebar}

```{python}
from shiny import render, ui
from shiny.express import render, ui
ui.input_select("x", "Variable:",
choices=["bill_length_mm", "bill_depth_mm"])
ui.input_select("dist", "Distribution:", choices=["hist", "kde"])
Expand Down
6 changes: 3 additions & 3 deletions docs/dashboards/_examples/inputs/inline-toolbar.qmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Palmer Penguins"
author: "Cobblepot Analytics"
format:
format:
dashboard:
orientation: columns
server: shiny
Expand All @@ -13,12 +13,12 @@ penguins = sns.load_dataset("penguins")
```


## Column
## Column

### {.toolbar}

```{python}
from shiny import render, ui
from shiny.express import render, ui
ui.input_select("dist", "Distribution:", choices=["hist", "kde"])
ui.input_checkbox("rug", "Show rug marks", value = False)
```
Expand Down
2 changes: 1 addition & 1 deletion docs/dashboards/_examples/inputs/input-panel.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ penguins = sns.load_dataset("penguins")

```{python}
#| content: card-toolbar
from shiny import render, ui
from shiny.express import render, ui
ui.input_select("x", "Variable:",
choices=["bill_length_mm", "bill_depth_mm"])
ui.input_select("dist", "Distribution:", choices=["hist", "kde"])
Expand Down
2 changes: 1 addition & 1 deletion docs/dashboards/_examples/inputs/page-sidebar.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ penguins = sns.load_dataset("penguins")
## {.sidebar}

```{python}
from shiny import render, ui
from shiny.express import render, ui
ui.input_select("x", "Variable:",
choices=["bill_length_mm", "bill_depth_mm"])
ui.input_select("dist", "Distribution:", choices=["hist", "kde"])
Expand Down
3 changes: 2 additions & 1 deletion docs/dashboards/_examples/inputs/right-sidebar.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ server: shiny

```{python}
#| context: setup
from shiny import render, reactive, ui
from shiny import reactive
from shiny.express import render, ui
import seaborn as sns
penguins = sns.load_dataset("penguins")
species = list(penguins["species"].value_counts().index)
Expand Down
2 changes: 1 addition & 1 deletion docs/dashboards/_examples/inputs/toolbar.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ server: shiny
---

```{python}
from shiny import ui, render
from shiny.express import ui, render
import seaborn as sns
penguins = sns.load_dataset("penguins")
```
Expand Down
3 changes: 2 additions & 1 deletion docs/dashboards/_examples/shiny-global-sidebar.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ islands = list(penguins["island"].value_counts().index)
![](images/penguins.png){width="80%"}

```{python}
from shiny import render, reactive, ui
from shiny import reactive
from shiny.express import render, ui

ui.input_checkbox_group(
"species", "Species:",
Expand Down
2 changes: 1 addition & 1 deletion docs/dashboards/_examples/shiny-python-simple.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ penguins = sns.load_dataset("penguins")
## {.sidebar}

```{python}
from shiny import render, ui
from shiny.express import render, ui
ui.input_select("x", "Variable:",
choices=["bill_length_mm", "bill_depth_mm"])
ui.input_select("dist", "Distribution:", choices=["hist", "kde"])
Expand Down
3 changes: 2 additions & 1 deletion docs/dashboards/_examples/shiny-sidebar.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ islands = list(penguins["island"].value_counts().index)
![](images/penguins.png){width="80%"}

```{python}
from shiny import render, reactive, ui
from shiny import reactive
from shiny.express import render, ui

ui.input_checkbox_group(
"species", "Species:",
Expand Down
20 changes: 10 additions & 10 deletions docs/dashboards/_inputs.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ Sidebars are a great place to group inputs for Shiny interactive dashboards. To
title: "Sidebar"
format: dashboard
---

## {.sidebar}

```{{python}}
```

## Column
## Column

```{{python}}
```
Expand All @@ -36,7 +36,7 @@ If you have a dashboard with [multiple pages](#pages), you may want the sidebar
title: "Sidebar"
format: dashboard
---

# {.sidebar}

Sidebar content
Expand Down Expand Up @@ -64,11 +64,11 @@ title: "Toolbar"
format: dashboard
server: shiny
---

## {.toolbar}

```{{python}}
from shiny import ui, render
from shiny.express import ui, render
ui.input_select("x", "Variable:",
choices=["bill_length_mm", "bill_depth_mm"])
ui.input_select("dist", "Distribution:", choices=["hist", "kde"])
Expand Down Expand Up @@ -97,12 +97,12 @@ title: "Toolbar"
format: dashboard
server: shiny
---

# {.toolbar}

Toolbar content

# Page 1
# Page 1

```{{python}}
```
Expand All @@ -118,11 +118,11 @@ Toolbar content

In some cases you may want to marry inputs more directly to a single output. To do this, define a card toolbar immediately above the cell that generates the output. You can do this by either adding the `content: card-toolbar` option to a cell or by creating a div with the `.card-toolbar` class. For example:

```` {.python .pymd}
```` {.python .pymd}
```{{python}}
#| title: Penguin Bills
#| content: card-toolbar
from shiny import ui, render
from shiny.express import ui, render
ui.input_select("x", "Variable:",
choices=["bill_length_mm", "bill_depth_mm"])
ui.input_select("dist", "Distribution:", choices=["hist", "kde"])
Expand Down
2 changes: 1 addition & 1 deletion docs/dashboards/data-display.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ Use the `ui.value_box()` function within a function decorated with `@render.ui`.

```` python
```{{python}}
from shiny import render, ui
from shiny.express import render, ui
@render.ui
def value():
return ui.value_box("Value", input.value())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ server: shiny # <1>
```{{python}} # <2>
#| context: setup
import seaborn as sns
from shiny import render, reactive, ui
from shiny import reactive
from shiny.express import render, ui
penguins = sns.load_dataset("penguins")
``` # <2>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
::: {.callout-note}
### Shiny Prerequisites

In order to use Shiny within Quarto documents you will need the latest version of the `shiny` (>=0.6.1) and `shinywidgets` (>=0.2.2) packages. You can install the latest version of these with:
In order to use Shiny within Quarto documents you will need the latest version of the `shiny` (>=0.9.0) and `shinywidgets` (>=0.3.1) packages. You can install the latest version of these with:

```{.bash}
pip install --upgrade shiny shinywidgets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ penguins = sns.load_dataset("penguins")
## {.sidebar} # <2>

```{{python}}
from shiny import render, ui
from shiny.express import render, ui
ui.input_select("x", "Variable:", # <3>
choices=["bill_length_mm", "bill_depth_mm"])
ui.input_select("dist", "Distribution:", choices=["hist", "kde"])
Expand Down
3 changes: 2 additions & 1 deletion docs/dashboards/interactivity/shiny-python/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ However, sometimes we have code that would be excessive to run for every user, a
```{{python}}
#| context: setup
import seaborn as sns
from shiny import render, reactive, ui
from shiny import reactive
from shiny.express import render, ui
penguins = sns.load_dataset("penguins")
```
````
Expand Down