Skip to content

Commit

Permalink
Don't attempt to display/render non-DOMWidget (i.e., Widget) objects (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cpsievert authored Feb 12, 2024
1 parent 597c2b5 commit 780f029
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to shinywidgets will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [UNRELEASED]

* `@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)

## [0.3.0] - 2024-01-25

* 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)
Expand Down
4 changes: 2 additions & 2 deletions shinywidgets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Top-level package for shinywidgets."""

__author__ = """Carson Sievert"""
__email__ = "carson@rstudio.com"
__version__ = "0.3.0"
__email__ = "carson@posit.co"
__version__ = "0.3.0.9000"

from ._as_widget import as_widget
from ._dependencies import bokeh_dependency
Expand Down
4 changes: 4 additions & 0 deletions shinywidgets/_render_widget_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ async def render(self) -> Jsonifiable | None:

self._widget = cast(WidgetT, widget)

# Don't actually display anything unless this is a DOMWidget
if not isinstance(widget, DOMWidget):
return None

return {
"model_id": str(
cast(
Expand Down

0 comments on commit 780f029

Please sign in to comment.