I want to display selected value of select() bokeh widget in my browser.
This is my code, where I have data frame and values and that is how my widget gets populated !!!
multi_select = Select (title = "Select Quarters" , value = str1, options = df)
This is how it is calling using this function!!
def function_to_call(attrname, old, new):
print(multi_select.value)
This is my HTML template which will call select value .
text=("""<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
{{ bokeh_css }}
{{ bokeh_js }}
</head>
<body>
<style type="text/css">
{% include 'styles.css' %}
</style>
{{ plot_div|indent(8) }}
{{ plot_script|indent(8) }}
<div>
<h1 style="color:#8CC43F">{selectval}</h1>
</div>
</body>
</html>
""")
Here {selectval} value is replacing my multi_select value from dropdown!!
m =multi_select.on_change('value',function_to_call)
text = text.format(selectval=m)
div = Div(text=text,width=200, height=100)
This is how i am calling the widget
curdoc().add_root(widgetbox(multi_select,div))
After doing this, it is still not displaying the value of my selected option from the select list. For example, if I am selecting Quarter-4 then it should display as text Quarter-4 in my div or textbox on "my browser" screen.
Any help will be appreciated. Thanks in advance !!
In your function you can change the text of the div widget directly
def function_to_call(attrname, old, new):
div.text = new
Here attrname
is 'value'
old
is the value of the Select widget before it was changed
new
is the new value of the Select widget