Skip to content

Commit 780f029

Browse files
authored
Don't attempt to display/render non-DOMWidget (i.e., Widget) objects (#134)
1 parent 597c2b5 commit 780f029

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to shinywidgets will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [UNRELEASED]
9+
10+
* `@render_widget` now works properly with `Widget`s that aren't `DOMWidget`s (i.e., widgets that aren't meant to be displayed directly). As a result, you can now use `@render_widget` to gain a reference to the widget instance, and then use that reference to update the widget's value. (#133)
11+
812
## [0.3.0] - 2024-01-25
913

1014
* The `@render_widget` decorator now attaches a `widget` (and `value`) attribute to the function it decorates. This allows for easier access to the widget instance (or value), and eliminates the need for `register_widget` (which is now soft deprecated). (#119)

shinywidgets/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""Top-level package for shinywidgets."""
22

33
__author__ = """Carson Sievert"""
4-
__email__ = "carson@rstudio.com"
5-
__version__ = "0.3.0"
4+
__email__ = "carson@posit.co"
5+
__version__ = "0.3.0.9000"
66

77
from ._as_widget import as_widget
88
from ._dependencies import bokeh_dependency

shinywidgets/_render_widget_base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ async def render(self) -> Jsonifiable | None:
8989

9090
self._widget = cast(WidgetT, widget)
9191

92+
# Don't actually display anything unless this is a DOMWidget
93+
if not isinstance(widget, DOMWidget):
94+
return None
95+
9296
return {
9397
"model_id": str(
9498
cast(

0 commit comments

Comments
 (0)