Hi everyone, I have two unsolid thoughts, where I need some confirmation/help:
First:
If you are using the standalone version of Bokeh, and you want to use a widget, which when the widget value was modified from the GUI (eg.: the user select a new value from the select), this new value is only available for the Javascript, and there is no way to have this new value in the Python layer.
Second:
The solution is to get the value of the widget in the Python layer is the Bokeh server approach.
Thank You, and have a nice day!
Additional information: (not necessary to read)
I am a new in Bokeh.
I would like to use Bokeh for modeling with widgets.
I currently tried the Standalone version of Bokeh with Jupyter notebook.
My goal is to get the values of the widgets on the Python layer, so for example:
import pandas as pd
import datetime as dt
from bokeh.plotting import figure, show, ColumnDataSource
from bokeh.io import output_notebook
from bokeh.models import BoxSelectTool, HoverTool, RangeSlider, RadioGroup, CustomJS
from bokeh.models.widgets import Select
from bokeh.models.callbacks import CustomJS
import numpy as np
from bokeh.layouts import column, row
select = Select(title="Features", value="SpO2", options=["SpO2", "HRV", "Cpnn", "CMCardiacEjectionTime", "CMBottomToPeakTime"])
def callback(value):
select.value = value
select.js_on_change("value", callback)
so then if I choose another value from the dropdown eg: Cpnn, I can use this value in the Python code, and not just in the JS layer as:
select.js_on_change('value', CustomJS(args=dict(select=select),
code="""
console.log(this.value);
var select = select
select.value = this.value;
select.change.emit()
alert(select.value)
"""
))
Summarized:
I want to use JS event listeners on widgets to call Python functions with their values.
Any help is greatly appreciated!
THX