Search code examples
pythonbokehdashboard

Is there a way to add a widget that only displays text to a Bokeh dashboard layout?


I just want to show the median income of a pandas dataframe column as text inside a widget/box that will change as more data is added over time.

Edit: I was able to find this documentation that helps you add a widget containing a DIV element.

http://docs.bokeh.org/en/1.3.2/docs/user_guide/interaction/widgets.html#div

Example:

from bokeh.io import output_file, show
from bokeh.models import Div

output_file("div.html")

div = Div(text="""Your <a href="https://en.wikipedia.org/wiki/HTML">HTML</a>-supported text is initialized with the <b>text</b> argument.  The
remaining div arguments are <b>width</b> and <b>height</b>. For this example, those values
are <i>200</i> and <i>100</i> respectively.""",
width=200, height=100)

show(div)

Solution

  • Use a Div and update by setting

    my_div.text = new_content