Skip to content

Commit 6bc0fb2

Browse files
Merge pull request #568 from karangattu/fix-pyshiny-cheatsheet
fix(pyshiny cheatsheet): Update Shiny Python cheatsheet
2 parents 953f709 + 643a197 commit 6bc0fb2

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

html/shiny-python.qmd

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Share your app in three ways:
7777
To deploy Shiny apps:
7878

7979
- Create a free or professional account at [shinyapps.io](https://www.shinyapps.io/)
80-
- Use the reconnect-python package to publish with `rsconnect deploy shiny <path to directory>`
80+
- Use the rsconnect-python package to publish with `rsconnect deploy shiny <path to directory>`
8181

8282
2. Purchase Posit Connect, a publishing platform for R and Python.
8383
[posit.co/products/enterprise/connect/](https://posit.co/products/enterprise/connect/)
@@ -113,15 +113,15 @@ An embedded Shinylive app:
113113

114114
Match ui.output\_\* functions to @render.\* decorators
115115

116-
| decorator | function |
117-
|------------------|------------------------------------------------------|
118-
| `@render.data_frame` | `ui.output_data_frame(id)` |
119-
| `@render.image` | `ui.output_image(id, width, height, click, dblclick, hover, brush, inline)` |
120-
| `@render.plot` | `ui.output_plot(id, width, height, click, dblclick, hover, brush, inline)` |
121-
| `@render.table` | `ui.output_table(id)` |
122-
| `@render.text` | `ui.output_text(id, container, inline)` also `ui.output_text_verbatim()` |
123-
| `@render.ui` | `ui.output_ui(id, inline, container, ...)` also `ui.output_html()` |
124-
| `@sessiom.download` | `ui.output_download_button(id, label, icon,...)` |
116+
| decorator | function |
117+
|---------------------|---------------------------------------------------|
118+
| `@render.data_frame` | `ui.output_data_frame(id)` |
119+
| `@render.image` | `ui.output_image(id, width, height, click, dblclick, hover, brush, inline)` |
120+
| `@render.plot` | `ui.output_plot(id, width, height, click, dblclick, hover, brush, inline)` |
121+
| `@render.table` | `ui.output_table(id)` |
122+
| `@render.text` | `ui.output_text(id, container, inline)` also `ui.output_text_verbatim()` |
123+
| `@render.ui` | `ui.output_ui(id, inline, container, ...)` |
124+
| `@render.download` | `ui.download_button(id, label, icon, width,...)` |
125125

126126
: Table of `@render.*()` decorators and their associated `ui.output_*()` functions.
127127

@@ -134,6 +134,8 @@ Input values are reactive and need to be called as `input.<id>()`.
134134

135135
- `ui.input_action_link(id, label, icon, ...)`
136136

137+
- `ui.input_task_button(id, label, icon, label_busy, icon_busy, width, type, auto_reset)`
138+
137139
- `ui.input_checkbox(id, label, value, width)`
138140

139141
- `ui.input_checkbox_group(id, label, choices, selected, inline, width)`
@@ -150,13 +152,15 @@ Input values are reactive and need to be called as `input.<id>()`.
150152

151153
- `ui.input_radio_buttons(id, label, choices, selected, inline, width)`
152154

153-
- `ui.input_select(id, label, choices, selected, multiple, selectize, width, size) Also ui.input_selectize()`
155+
- `ui.input_select(id, label, choices, selected, multiple, selectize, width, size, remove_button, options)`
156+
157+
- `ui.input_selectize(id,label, choices, selected, multiple, width, remove_button, options)`
154158

155159
- `ui.input_slider(id, label, min, max, value, step, ticks, animate, width, sep, pre, post, timeFormat, timezone, dragRange)`
156160

157161
- `ui.input_switch(id, label, value, width)`
158162

159-
- `ui.input_text(id, label, value, width, placeholder, autocomplete, spellcheck) Also ui.input_text_area()`
163+
- `ui.input_text(id, label, value, width, placeholder, autocomplete, spellcheck)` Also `ui.input_text_area()`
160164

161165
<!-- page 2 -->
162166

@@ -174,7 +178,7 @@ Call a reactive value from within the arguments of one of these functions to avo
174178

175179
- Create your own reactive values
176180
- `ui.input_*()`
177-
- \`reactive.Value()\`\`
181+
- \`reactive.value()\`\`
178182
- `@reactive.file_reader()`
179183
- `@reactive.poll()`
180184
- Perform side effects
@@ -204,7 +208,7 @@ Call a reactive value from within the arguments of one of these functions to avo
204208
)
205209
206210
def server(input, output, session):
207-
rv = reactive.Value()
211+
rv = reactive.value()
208212
rv.set(5)
209213
#...
210214
```
@@ -231,10 +235,9 @@ Call a reactive value from within the arguments of one of these functions to avo
231235
```{python}
232236
#...
233237
def server(input, output, session ):
234-
@reactive.Calc
235-
@reactive.event(input.a)
238+
@reactive.event(input.a)
236239
def re():
237-
return input.b()
240+
return input.b()
238241
#...
239242
```
240243
@@ -307,7 +310,7 @@ Add elements as arguments of the layout functions.
307310
- `ui.page_sidebar()`
308311
309312
```{python}
310-
app_ui = ui.page_sider(
313+
app_ui = ui.page_sidebar(
311314
ui.sidebar("Sidebar", bg="#f8f8f),
312315
"Main content",
313316
)
@@ -348,9 +351,9 @@ Use the shinyswatch package to add existing bootstrap themes to your Shiny app u
348351
```{python}
349352
import shinyswatch
350353
351-
app_ui = ui.page_fluid(
352-
shinyswatch.theme.darkly(),
354+
app_ui = ui.page_fluid(
353355
# ...
356+
theme=shinyswatch.theme.darkly,
354357
)
355358
```
356359

@@ -447,7 +450,7 @@ Shiny for Python is quite similar to Shiny for R with a few important difference
447450
return input.x() + 1
448451
```
449452
450-
6. Use `reactive.Value()` instead of `reactiveVal()`
453+
6. Use `reactive.value()` instead of `reactiveVal()`
451454
452455
- R
453456

keynotes/shiny-python.key

10.6 KB
Binary file not shown.

shiny-python.pdf

177 KB
Binary file not shown.

0 commit comments

Comments
 (0)