How do I get the state of an interactive plot?

I’m doing something like this for an embedded plot in jupyter: bokeh/notebook_embed.ipynb at 2.4.2 · bokeh/bokeh · GitHub

And it works great… I just can’t figure out how to get the state of the widgets back into python.

For example, if I wanted to read the state of the slider widget in that example, how would I do that?

I have tried passing in references to use to hold the state and then reading those, but that isn’t working. The show function doesn’t return anything, so I can’t get anything from that.

Any ideas? Is this possible?

Hi @spott Bokeh apps are largely callback based. To get an update when a model property changes, would would add a Python callback with obj.on_change("propname", callback) and then you can access the new value (edit: or any current property value for any other model) in callback. There are lots of examples of using on_change in the apps directory of the repo:

(Note that this link goes to the upcoming 3.0 release branch, since the repo structure is changing considerably, but all or most of the examples there should still apply to Bokeh 2.4.x)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.