I am writing in python and have all my functionalities for analyzing datasets. Now, I would like to turn these functions into a user-ready application that, in a sense, works like an .exe app. In bokeh, I saw that you could create a plot, table...etc; however, is it possible to create a GUI where you can:
basically it can go from one page to the other kind of like a webpage where you click one button it links you to the next page for another purpose and home to go back. Could you potentially do this with bokeh?
There are several examples of data web applications created using Bokeh at demo.bokeh.org. Here is one modeled after the "Shiny Movie Explorer", but written in pure Python/Bokeh (instead of R/Shiny).
You can find much more details about creating and deploying Bokeh applications in the Running a Bokeh Server chapter of the docs.
Here is a complete (but simpler) example that demonstrates the basic gist and structure:
import numpy as np
from bokeh.io import curdoc
from bokeh.layouts import column
from bokeh.models import ColumnDataSource, Slider
from bokeh.plotting import figure
# Set up data
x = np.linspace(0, 4*np.pi, 200)
y = np.sin(x)
source = ColumnDataSource(data=dict(x=x, y=y))
# Set up plot
plot = figure(title="my sine wave")
plot.line('x', 'y', source=source, line_width=3, line_alpha=0.6)
# Set up widgets
freq = Slider(title="frequency", value=1.0, start=0.1, end=5.1, step=0.1)
# Set up callbacks
def update_data(attrname, old, new):
# Get the current slider values and set new data
k = freq.value
x = np.linspace(0, 4*np.pi, 200)
y = np.sin(k*x)
source.data = dict(x=x, y=y)
freq.on_change('value', update_data)
# Set up layouts and add to document
curdoc().add_root(column(freq, plot))
curdoc().title = "Sliders"
To run this locally you'd execute:
bokeh serve --show myscript.py
For more sophisticated deployments (i.e. with proxies) or to embed directly in e.g. Flask, see the docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With