Skip to main content

bokeh extension for jsmol

Project description

JSmol bokeh extension

Custom extension to bokeh for JSmol.

Installation

pip install jsmol-bokeh-extension

Usage

Below a complete example.py demonstrating how to use the jsmol bokeh extension:

rom bokeh.models import ColumnDataSource
from bokeh.io import show, curdoc
from bokeh.models.widgets import Button, TextInput
from bokeh.layouts import layout, widgetbox

from jsmol_bokeh_extension import JSMol

script_source = ColumnDataSource()

info = dict(
    height="100%",
    width="100%",
    serverURL="https://chemapps.stolaf.edu/jmol/jsmol/php/jsmol.php",
    use="HTML5",
    j2sPath="https://chemapps.stolaf.edu/jmol/jsmol/j2s",
    script=
    "background black;load https://chemapps.stolaf.edu/jmol/jsmol-2013-09-18/data/caffeine.mol",
)

applet = JSMol(
    width=600,
    height=600,
    script_source=script_source,
    info=info,
)

button = Button(label='Execute')
inp_script = TextInput(value='background white;')


def run_script():
    script_source.data['script'] = [inp_script.value]


button.on_click(run_script)

ly = layout([applet, widgetbox(button, inp_script)])

show(ly)
curdoc().add_root(ly)

Note: The example can be run both using bokeh and bokeh server:

# run locally (displays structure but button won't work)
python example.py

# run using bokeh server (displays structure and button should work)
bokeh serve example.py --show

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jsmol-bokeh-extension-0.1.0.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distribution

jsmol_bokeh_extension-0.1.0-py2-none-any.whl (3.5 kB view hashes)

Uploaded Python 2

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page