I have inherited the bokeh button class and am trying to get this simple example running with the bokeh server:
import pandas as pd
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure
from bokeh.io import curdoc, push_session
import bokeh.layouts
class BUTTON(bokeh.models.widgets.Button):
"""
This class inherits from bokeh's Button and provides a built in way to add
on_click actions
"""
__subtype__ = 'Dashboard Button'
__view_model__ = 'Button'
def __init__(self, **kwargs):
super(bokeh.models.widgets.Button, self).__init__(**kwargs)
p = figure()
p.circle([0], [0])
b = BUTTON(label=‘Play’)
view = bokeh.layouts.layout([[b, p]])
doc = curdoc()
#doc.add_root(b) # Note that this line is commented out and so it works!
doc.add_root(p)
session = push_session(doc)
session.show()
···
So I fire up bokeh serve and then run python example.py which plots a circle. However, if I uncomment the doc.add_root(b) then I get the following server error:
2016-12-30 15:07:40,154 WebSocket connection opened
2016-12-30 15:07:40,154 ServerConnection created
2016-12-30 15:07:40,161 error handling message Message ‘PUSH-DOC’ (revision 1): KeyError(u"View model name ‘Dashboard Button’ not found",)
2016-12-30 15:07:40,235 WebSocket connection closed: code=None, reason=None
Ultimately, I’d like to run this code example from within a jupyter notebook but will settle for running it as above. Any guidance would be greatly appreciated.