{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from bokeh.io import output_notebook\n", "import bokeh.models.widgets as bk\n", "import jupyter_bokeh as jbk\n", "import ipywidgets as ip" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "output_notebook()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "bk_slider = bk.Slider(start=0, end=10, value=0)\n", "ip_slider = ip.IntSlider(min=0, max=10, value=0)\n", "\n", "def on_change_bk(_attr, _old, new):\n", " ip_slider.value = new\n", " \n", "def on_change_ip(change):\n", " new = change[\"new\"]\n", " bk_slider.value = new\n", " \n", "bk_slider.on_change(\"value\", on_change_bk)\n", "ip_slider.observe(on_change_ip, names=\"value\")\n", "\n", "ip.VBox(children=[jbk.BokehModel(bk_slider), ip_slider])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "bk_slider.value = 5" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.4" } }, "nbformat": 4, "nbformat_minor": 4 }