You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/dashboards/interactivity/shiny-python/index.qmd
+15-10Lines changed: 15 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -44,9 +44,14 @@ Make sure each input ID in your Shiny dashboard is unique. If you use the same I
44
44
45
45
The second argument for each input function is usually a human-readable string that will be displayed next to the input control. For example, the `ui.input_select()` function passes `"Variable:"`as the second argument, which is why the select box has the label "Variable:" next to it.
46
46
47
-
<!--
48
-
TODO: Introduce components gallery
49
-
-->
47
+
````{.python .pymd}
48
+
```{{python}}
49
+
ui.input_select("x", label="Variable:",
50
+
choices=["bill_length_mm", "bill_depth_mm"])
51
+
```
52
+
````
53
+
54
+
This example only uses two types of inputs, but Shiny has many more. See the [Shiny Component Browser](https://jcheng.shinyapps.io/shiny-component-browser/) for previews and code snippets.
50
55
51
56
In many dashboards, it's desirable to visually gather all of your input controls into a sidebar. You can do this by adding the `.sidebar` class to a level 2 header, as in the `## {.sidebar}` line above.
52
57
@@ -72,17 +77,15 @@ The `input.x()` and `input.rug()` method calls are retrieving the values of the
72
77
73
78
Note that our code never calls the `displot()` function! Just the act of defining the function, and decorating it with `@render.plot`, is enough to tell Shiny and Quarto to:
74
79
75
-
1. Insert a plot into the dashboard at this location.
76
-
2. Use the function body to create the plot.
77
-
3. Automatically re-run the function body whenever the values of `input.x()`, `input.rug()`, or `input.dist()` change due to user interaction, and use the result to update the existing plot.
78
-
79
-
This example only contains a single `@render.plot` output, but it's possible for Shiny apps to contain multiple outputs, and outputs of different types, as you'll see in the following example.
80
+
* Insert a plot into the dashboard at this location.
81
+
* Use the function body to create the plot.
82
+
* Automatically re-run the function body whenever the values of `input.x()`, `input.rug()`, or `input.dist()` change due to user interaction, and use the result to update the existing plot.
80
83
81
-
<!-- TODO: Link to output gallery -->
84
+
This example only contains a single `@render.plot`output, but it's possible for Shiny apps to contain multiple outputs, and outputs of different types, as you'll see in the following example. See the [Shiny Component Browser](https://jcheng.shinyapps.io/shiny-component-browser/#outputs) to see what's available.
82
85
83
86
### Reactive Programming
84
87
85
-
In the previous section, we said that the `displot` function would re-run whenever any of the inputs it referred to changed. Shiny is a **reactive programming** framework, meaning it automatically tracks the relationships between inputs and outputs in your app. When an input changes, only outputs that are affected by that input are re-rendered. This is a powerful feature that makes it easy to create dashboards that respond to user input efficiently.
88
+
In the previous section, we said that the `displot` function would re-run _automatically_whenever any of the inputs it referred to changed. Shiny is a **reactive programming** framework, meaning it takes care of tracking the relationships between inputs and outputs in your app. When an input changes, only outputs that are affected by that input are re-rendered. This is a powerful feature that makes it easy to create dashboards that respond to user input efficiently.
86
89
87
90
::: {.callout-note}
88
91
The `input` object is designed to be tracked by Shiny's reactive framework,
@@ -176,4 +179,6 @@ To learn more about Shiny for Python interactive documents see the following art
176
179
177
180
-[Execution Contexts](execution.qmd) goes in depth on when different code cells run (e.g. rendering vs. serving).
178
181
182
+
-[Shiny Component Browser](https://jcheng.shinyapps.io/shiny-component-browser/) gives a preview of Shiny's built-in input and output widgets.
183
+
179
184
-[Shiny for Python](https://shiny.posit.co/py/) provides in-depth documentation on all of the available UI and ouput widgets, as well as conceptual discussions on how things work.
0 commit comments