Skip to content

Commit c5ebaf4

Browse files
authored
Merge pull request #1049 from quarto-dev/shiny-express
Change imports from `shiny` to `shiny.express`
2 parents 88ffecd + 6dabad4 commit c5ebaf4

19 files changed

+78
-41
lines changed

docs/dashboards/_examples/app.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# This file generated by Quarto; do not edit by hand.
2+
# shiny_mode: core
23

34
from __future__ import annotations
45

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

1516
# ========================================================================
1617

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

3334

3435

36+
return None
37+
3538

3639
_static_assets = ["shiny-python-simple_files"]
3740
_static_assets = {"/" + sa: Path(__file__).parent / sa for sa in _static_assets}
Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,71 @@
11
# This file generated by Quarto; do not edit by hand.
2+
# shiny_mode: core
23

34
from __future__ import annotations
45

56
from pathlib import Path
67
from shiny import App, Inputs, Outputs, Session, ui
78

9+
import seaborn as sns
10+
penguins = sns.load_dataset("penguins")
11+
species = list(penguins["species"].value_counts().index)
12+
islands = list(penguins["island"].value_counts().index)
13+
14+
# ========================================================================
15+
816

917

1018

1119
def server(input: Inputs, output: Outputs, session: Session) -> None:
12-
from shiny import ui, render
13-
import seaborn as sns
14-
penguins = sns.load_dataset("penguins")
20+
from shiny import reactive
21+
from shiny.express import render, ui
22+
ui.input_checkbox_group(
23+
"species", "Species:",
24+
species, selected = species
25+
)
26+
27+
# ========================================================================
28+
29+
ui.input_checkbox_group(
30+
"islands", "Islands:",
31+
islands, selected = islands
32+
)
1533

1634
# ========================================================================
1735

18-
ui.input_select("x", "Variable:",
19-
choices=["bill_length_mm", "bill_depth_mm"])
20-
ui.input_select("dist", "Distribution:", choices=["hist", "kde"])
36+
ui.input_select("dist", "Distribution:", choices=["kde", "hist"])
2137
ui.input_checkbox("rug", "Show rug marks", value = False)
2238

2339
# ========================================================================
2440

41+
@reactive.calc
42+
def filtered_penguins():
43+
data = penguins[penguins["species"].isin(input.species())]
44+
data = data[data["island"].isin(input.islands())]
45+
return data
46+
47+
# ========================================================================
48+
2549
@render.plot
26-
def displot():
27-
sns.displot(
28-
data=penguins, hue="species", multiple="stack",
29-
x=input.x(), rug=input.rug(), kind=input.dist())
50+
def depth():
51+
return sns.displot(
52+
filtered_penguins(), x = "bill_depth_mm",
53+
hue = "species", kind = input.dist(),
54+
fill = True, rug=input.rug()
55+
)
3056

3157
# ========================================================================
3258

3359

3460

61+
return None
62+
3563

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

3967
app = App(
40-
Path(__file__).parent / "toolbar.html",
68+
Path(__file__).parent / "column-layout.html",
4169
server,
4270
static_assets=_static_assets,
4371
)

docs/dashboards/_examples/inputs/card-toolbar.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ penguins = sns.load_dataset("penguins")
1111

1212
```{python}
1313
#| content: card-sidebar
14-
from shiny import ui, render
14+
from shiny.express import ui, render
1515
ui.input_select("x", "Variable:",
1616
choices=["bill_length_mm", "bill_depth_mm"])
1717
ui.input_select("dist", "Distribution:", choices=["hist", "kde"])

docs/dashboards/_examples/inputs/column-layout.qmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ islands = list(penguins["island"].value_counts().index)
1616
::: {.inputs header-for="next" layout-ncol="3"}
1717

1818
```{python}
19-
from shiny import render, reactive, ui
19+
from shiny import reactive
20+
from shiny.express import render, ui
2021
ui.input_checkbox_group(
2122
"species", "Species:",
2223
species, selected = species

docs/dashboards/_examples/inputs/inline-sidebar.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ penguins = sns.load_dataset("penguins")
1616
### {.sidebar}
1717

1818
```{python}
19-
from shiny import render, ui
19+
from shiny.express import render, ui
2020
ui.input_select("x", "Variable:",
2121
choices=["bill_length_mm", "bill_depth_mm"])
2222
ui.input_select("dist", "Distribution:", choices=["hist", "kde"])

docs/dashboards/_examples/inputs/inline-toolbar.qmd

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Palmer Penguins"
33
author: "Cobblepot Analytics"
4-
format:
4+
format:
55
dashboard:
66
orientation: columns
77
server: shiny
@@ -13,12 +13,12 @@ penguins = sns.load_dataset("penguins")
1313
```
1414

1515

16-
## Column
16+
## Column
1717

1818
### {.toolbar}
1919

2020
```{python}
21-
from shiny import render, ui
21+
from shiny.express import render, ui
2222
ui.input_select("dist", "Distribution:", choices=["hist", "kde"])
2323
ui.input_checkbox("rug", "Show rug marks", value = False)
2424
```

docs/dashboards/_examples/inputs/input-panel.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ penguins = sns.load_dataset("penguins")
2121

2222
```{python}
2323
#| content: card-toolbar
24-
from shiny import render, ui
24+
from shiny.express import render, ui
2525
ui.input_select("x", "Variable:",
2626
choices=["bill_length_mm", "bill_depth_mm"])
2727
ui.input_select("dist", "Distribution:", choices=["hist", "kde"])

docs/dashboards/_examples/inputs/page-sidebar.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ penguins = sns.load_dataset("penguins")
1212
## {.sidebar}
1313

1414
```{python}
15-
from shiny import render, ui
15+
from shiny.express import render, ui
1616
ui.input_select("x", "Variable:",
1717
choices=["bill_length_mm", "bill_depth_mm"])
1818
ui.input_select("dist", "Distribution:", choices=["hist", "kde"])

docs/dashboards/_examples/inputs/right-sidebar.qmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ server: shiny
77

88
```{python}
99
#| context: setup
10-
from shiny import render, reactive, ui
10+
from shiny import reactive
11+
from shiny.express import render, ui
1112
import seaborn as sns
1213
penguins = sns.load_dataset("penguins")
1314
species = list(penguins["species"].value_counts().index)

docs/dashboards/_examples/inputs/toolbar.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ server: shiny
55
---
66

77
```{python}
8-
from shiny import ui, render
8+
from shiny.express import ui, render
99
import seaborn as sns
1010
penguins = sns.load_dataset("penguins")
1111
```

0 commit comments

Comments
 (0)