Skip to content

Instantly share code, notes, and snippets.

@nicain
Created June 14, 2017 04:19
Show Gist options
  • Save nicain/dfaa88e98a4a373b11ce2319e349da8d to your computer and use it in GitHub Desktop.
Save nicain/dfaa88e98a4a373b11ce2319e349da8d to your computer and use it in GitHub Desktop.
from bokeh.io import show, curdoc
from bokeh.models.widgets import Button
from bokeh.layouts import row, widgetbox
from bokeh.models import ColumnDataSource, CustomJS
from bokeh import events
button = Button(label = 'Send HelloWorld to console')
source = ColumnDataSource(data=dict())
jscb = CustomJS(code='''
console.log('HelloWorld');
''')
source.js_on_change('data', jscb)
def send_hello_world_to_console():
source.data = {'data':['str']}
print 'Confirm that python CB worked'
button.on_click(send_hello_world_to_console)
# Comment this in to make sure that JS code is correct
# button.js_on_event(events.ButtonClick, jscb)
curdoc().add_root(row(widgetbox(button)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment