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: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
11
11
* Closed #94: New `SHINYWIDGETS_CDN` and `SHINYWIDGETS_CDN_ONLY` environment variables were added to more easily specify the CDN provider. Also, the default provider has changed from <unpkg.com> to <cdn.jsdelivr.net/npm> (#95)
12
12
* A warning is no longer issued (by default) when the path to a local widget extension is not found. This is because, if an internet connection is available, the widget assests are still loaded via CDN. To restore the previous behavior, set the `SHINYWIDGETS_EXTENSION_WARNING` environment variable to `"true"`. (#95)
13
13
* Closed #14: Added a `bokeh_dependency()` function to simplify use of bokeh widgets. (#85)
14
+
* Closed #89: Exported the `as_widget()` function to attempt coercion of objects into ipywidgets. Internally, `{shinywidgets}` uses it to implictly coerce objects into ipywidgets, but it can be also useful to explicitly coerce objects before passing to `register_widget()` (so that the ipywidget can then be updated in-place and/or used as a reactive value (`reactive_read()`)). (#90)
That said, `{shinywidgets}` can also "directly" render objects that don't inherit from `Widget`, but have a known way of coercing into a `Widget` instance. This list currently includes:
67
24
68
-
# Everytime the map's bounds change, update the output message (3)
69
-
@output
70
-
@render.text
71
-
defmap_bounds():
72
-
b = reactive_read(map, "bounds")
73
-
lat = [b[0][0], b[0][1]]
74
-
lon = [b[1][0], b[1][1]]
75
-
returnf"The current latitude is {lat} and longitude is {lon}"
25
+
* Altair charts (via the [vega](https://pypi.org/project/vega/) package).
26
+
* Bokeh widgets (via the [jupyter_bokeh](https://github.com/bokeh/jupyter_bokeh) package).
27
+
* Plotly's `Figure` class (via `FigureWidget`).
28
+
* Pydeck's `Deck` class (via it's `.show()` method).
76
29
77
-
app = App(app_ui, server)
78
-
```
30
+
[See here](https://github.com/rstudio/py-shinywidgets/blob/main/shinywidgets/_as_widget.py) for more details on how these objects are coerced into `Widget` instances, and if you know of other packages that should be added to this list, please [let us know](https://github.com/rstudio/py-shinywidgets/issues/new)
The style of programming above (display and mutate) is great for efficiently performing
85
-
partial updates to a widget. This is really useful when a widget needs to display lots
86
-
of data and also quickly handle partial updates; for example, toggling the visibility of
87
-
a fitted line on a scatterplot with lots of points:
34
+
Similar to how you have to run `bokeh.io.output_notebook()` to run `{bokeh}` in notebook, you also have to explicitly bring the JS/CSS dependencies to the Shiny app, which can be done this way:
88
35
89
36
```py
90
-
from shiny import*
91
-
from shinywidgets import output_widget, register_widget
92
-
import plotly.graph_objs as go
93
-
import numpy as np
94
-
from sklearn.linear_model import LinearRegression
95
-
96
-
# Generate some data and fit a linear regression
97
-
n =10000
98
-
d = np.random.RandomState(0).multivariate_normal([0, 0], [(1, 0.5), (0.5, 1)], n).T
99
-
fit = LinearRegression().fit(d[0].reshape(-1, 1), d[1])
To some extent, yes. As shown on the official [shinylive examples](https://shinylive.io/py/examples/), packages like plotly and ipyleaflet work (as long as you've provided the proper dependencies in a [`requirements.txt` file](https://shinylive.io/py/examples/#extra-packages)), but other packages like altair and qgrid may not work (at least currently) due to missing wheel files and/or dependencies with compiled code that can't be compiled to WebAssembly.
173
50
174
51
### How do I size the widget?
175
52
@@ -179,8 +56,8 @@ including `height` and `width`. So, given a `Widget` instance `w`, you should be
179
56
do something like:
180
57
181
58
```py
182
-
w.layout.height ="600px"
183
-
w.layout.width ="80%"
59
+
w.layout.height ="100%"
60
+
w.layout.width ="100%"
184
61
```
185
62
186
63
### How do I hide/show a widget?
@@ -204,18 +81,6 @@ w.layout.display = "none"
204
81
Yes! In fact this a crucial aspect to how packages like `{ipyleaflet}` work. In
205
82
`{ipyleaflet}`'s case, each [individual marker is a widget](https://ipyleaflet.readthedocs.io/en/latest/layers/circle_marker.html) which gets attached to a `Map()` via `.add_layer()`.
206
83
207
-
### Does `{shinywidgets}` work with Shinylive?
208
-
209
-
Shinylive allows some Shiny apps to be statically served (i.e., run entirely in the
210
-
browser). [py-shinylive](https://github.com/rstudio/py-shinylive) does have some special
211
-
support for `{shinywidgets}` and it's dependencies, which should make most widgets work
212
-
out-of-the-box.
213
-
214
-
In some cases, the package(s) that you want to use may not come pre-bundled with
215
-
`{shinywidgets}`; and in that case, you can [include a `requirements.txt`
216
-
file](https://shinylive.io/py/examples/#extra-packages) to pre-install those other
217
-
packages
218
-
219
84
## Troubleshooting
220
85
221
86
If after [installing](#installation)`{shinywidgets}`, you have trouble rendering widgets,
@@ -243,7 +108,8 @@ app_ui = ui.page_fluid(
243
108
# ...
244
109
)
245
110
```
246
-
```
111
+
112
+
247
113
#### Other widgets?
248
114
249
115
Know of another widget that requires initialization code? [Please let us know about
0 commit comments