diff --git a/docs/dashboards/_examples/app.py b/docs/dashboards/_examples/app.py index 6455407d5..9ac8a27b1 100644 --- a/docs/dashboards/_examples/app.py +++ b/docs/dashboards/_examples/app.py @@ -1,4 +1,5 @@ # This file generated by Quarto; do not edit by hand. +# shiny_mode: core from __future__ import annotations @@ -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"]) @@ -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} diff --git a/docs/dashboards/_examples/inputs/app.py b/docs/dashboards/_examples/inputs/app.py index 6ff6f5545..42841e9a1 100644 --- a/docs/dashboards/_examples/inputs/app.py +++ b/docs/dashboards/_examples/inputs/app.py @@ -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, ) diff --git a/docs/dashboards/_examples/inputs/card-toolbar.qmd b/docs/dashboards/_examples/inputs/card-toolbar.qmd index 16192c042..ac23c3fe8 100644 --- a/docs/dashboards/_examples/inputs/card-toolbar.qmd +++ b/docs/dashboards/_examples/inputs/card-toolbar.qmd @@ -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"]) diff --git a/docs/dashboards/_examples/inputs/column-layout.qmd b/docs/dashboards/_examples/inputs/column-layout.qmd index 5586d25ff..694a5fe97 100644 --- a/docs/dashboards/_examples/inputs/column-layout.qmd +++ b/docs/dashboards/_examples/inputs/column-layout.qmd @@ -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 diff --git a/docs/dashboards/_examples/inputs/inline-sidebar.qmd b/docs/dashboards/_examples/inputs/inline-sidebar.qmd index ca1eed43b..e8d199725 100644 --- a/docs/dashboards/_examples/inputs/inline-sidebar.qmd +++ b/docs/dashboards/_examples/inputs/inline-sidebar.qmd @@ -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"]) diff --git a/docs/dashboards/_examples/inputs/inline-toolbar.qmd b/docs/dashboards/_examples/inputs/inline-toolbar.qmd index a44f91825..69300161d 100644 --- a/docs/dashboards/_examples/inputs/inline-toolbar.qmd +++ b/docs/dashboards/_examples/inputs/inline-toolbar.qmd @@ -1,7 +1,7 @@ --- title: "Palmer Penguins" author: "Cobblepot Analytics" -format: +format: dashboard: orientation: columns server: shiny @@ -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) ``` diff --git a/docs/dashboards/_examples/inputs/input-panel.qmd b/docs/dashboards/_examples/inputs/input-panel.qmd index 8ee6d4bcb..82e71b00f 100644 --- a/docs/dashboards/_examples/inputs/input-panel.qmd +++ b/docs/dashboards/_examples/inputs/input-panel.qmd @@ -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"]) diff --git a/docs/dashboards/_examples/inputs/page-sidebar.qmd b/docs/dashboards/_examples/inputs/page-sidebar.qmd index 8c6340ca5..73b1e1d74 100644 --- a/docs/dashboards/_examples/inputs/page-sidebar.qmd +++ b/docs/dashboards/_examples/inputs/page-sidebar.qmd @@ -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"]) diff --git a/docs/dashboards/_examples/inputs/right-sidebar.qmd b/docs/dashboards/_examples/inputs/right-sidebar.qmd index 88eb4b8bb..b1e758459 100644 --- a/docs/dashboards/_examples/inputs/right-sidebar.qmd +++ b/docs/dashboards/_examples/inputs/right-sidebar.qmd @@ -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) diff --git a/docs/dashboards/_examples/inputs/toolbar.qmd b/docs/dashboards/_examples/inputs/toolbar.qmd index f23a99a62..dda7f8918 100644 --- a/docs/dashboards/_examples/inputs/toolbar.qmd +++ b/docs/dashboards/_examples/inputs/toolbar.qmd @@ -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") ``` diff --git a/docs/dashboards/_examples/shiny-global-sidebar.qmd b/docs/dashboards/_examples/shiny-global-sidebar.qmd index 9c948994d..ec88f86a5 100644 --- a/docs/dashboards/_examples/shiny-global-sidebar.qmd +++ b/docs/dashboards/_examples/shiny-global-sidebar.qmd @@ -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:", diff --git a/docs/dashboards/_examples/shiny-python-simple.qmd b/docs/dashboards/_examples/shiny-python-simple.qmd index 8c6340ca5..73b1e1d74 100644 --- a/docs/dashboards/_examples/shiny-python-simple.qmd +++ b/docs/dashboards/_examples/shiny-python-simple.qmd @@ -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"]) diff --git a/docs/dashboards/_examples/shiny-sidebar.qmd b/docs/dashboards/_examples/shiny-sidebar.qmd index 6271b1669..b2b14feb9 100644 --- a/docs/dashboards/_examples/shiny-sidebar.qmd +++ b/docs/dashboards/_examples/shiny-sidebar.qmd @@ -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:", diff --git a/docs/dashboards/_inputs.qmd b/docs/dashboards/_inputs.qmd index cc3015769..7055c787a 100644 --- a/docs/dashboards/_inputs.qmd +++ b/docs/dashboards/_inputs.qmd @@ -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}} ``` @@ -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 @@ -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"]) @@ -97,12 +97,12 @@ title: "Toolbar" format: dashboard server: shiny --- - + # {.toolbar} Toolbar content -# Page 1 +# Page 1 ```{{python}} ``` @@ -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"]) diff --git a/docs/dashboards/data-display.qmd b/docs/dashboards/data-display.qmd index 4cf58fd9b..62de7ed38 100644 --- a/docs/dashboards/data-display.qmd +++ b/docs/dashboards/data-display.qmd @@ -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()) diff --git a/docs/dashboards/interactivity/shiny-python/_shiny-advanced.md b/docs/dashboards/interactivity/shiny-python/_shiny-advanced.md index dda9d8116..b0a526351 100644 --- a/docs/dashboards/interactivity/shiny-python/_shiny-advanced.md +++ b/docs/dashboards/interactivity/shiny-python/_shiny-advanced.md @@ -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> diff --git a/docs/dashboards/interactivity/shiny-python/_shiny-requirements.qmd b/docs/dashboards/interactivity/shiny-python/_shiny-requirements.qmd index 9534f2827..e5e207768 100644 --- a/docs/dashboards/interactivity/shiny-python/_shiny-requirements.qmd +++ b/docs/dashboards/interactivity/shiny-python/_shiny-requirements.qmd @@ -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 diff --git a/docs/dashboards/interactivity/shiny-python/_shiny-sidebar.md b/docs/dashboards/interactivity/shiny-python/_shiny-sidebar.md index 399ae2f06..94b21de59 100644 --- a/docs/dashboards/interactivity/shiny-python/_shiny-sidebar.md +++ b/docs/dashboards/interactivity/shiny-python/_shiny-sidebar.md @@ -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"]) diff --git a/docs/dashboards/interactivity/shiny-python/index.qmd b/docs/dashboards/interactivity/shiny-python/index.qmd index 87a9134af..ef6d6b657 100644 --- a/docs/dashboards/interactivity/shiny-python/index.qmd +++ b/docs/dashboards/interactivity/shiny-python/index.qmd @@ -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") ``` ````