On Jul 8, 2016, at 7:34 AM, 'the_driver02' via Bokeh Discussion - Public <[email protected]> wrote:
Okay, I found a solution. -> with bokeh server 0.12
First we save our python data in a ColumnDataSource.
In the python function we must trigger the ColumnDataSource.
Now, we can access the Data with CustomJS and change the options of the select field.
source = ColumnDataSource(data=dict(entry=,value=))
def getcols(attrname, old, new):
list=
table=selectviews.value
data = cursorS.execute("""
select column_name from ALL_TAB_COLUMNS
where TABLE_NAME='""" + table +"'")
y=data.fetchall()
for i in range(0,len(y)):
list.append(y[i][0])
source.data['entry'] = list
source.trigger('data', source.data, source.data)
callbacks = CustomJS(args=dict(source=source), code="""
var f = cb_obj.get('value');
var data = source.get('data')
s2.set('options', source.data['entry']);
s2.trigger('change');
""")
selectviews = Select(title="Views", options=views, value="",callback=callbacks)
selectviews.on_change("value",getcols)
s2 = Select(title="Select2", value='initial value in your dropdown')
callbacks.args["s2"] = s2
Am Mittwoch, 6. Juli 2016 16:42:27 UTC+2 schrieb the_driver02:
At the moment I use bokeh serve to plot some data from a database.
I want to select interactively from all my tables some data. With static lists I can generate my sql code and modify the ColumnDataSource. Plotting works fine.
But how can I modify a select widget?
The button "buttonshow" (example below) shows me (via print), that the list cols has successfully changed. But how can I update the options of my select widget "selectcols" ?
Is there a possibility to change bokeh widgets on a server?
a snippet from my testprogram:
from bokeh.models.widgets import Select, Button, Slider, CheckboxGroup, DateRangeSlider, DatePicker, TextInput
from bokeh.models import ColumnDataSource
import numpy as np
from bokeh.plotting import *
from bokeh.layouts import row, column, widgetbox
import cx_Oracle
views=["tbl_TDR","tbl_TEMP","tbl_FLUX"]
cols=
def getcols(attrname, old, new):
table=selectviews.value
data = cursorS.execute("""
select column_name from ALL_TAB_COLUMNS
where TABLE_NAME='""" + table +"'")
y=data.fetchall()
for i in range(0,len(y)):
cols.append(y[i][0])
print(cols)
def showcols():
print(cols)
selectviews = Select(title="Views", options=views, value="")
selectviews.on_change("value",getcols)
selectcols = Select(title="Cols", options=cols, value="")
buttonshow = Button(label="show")
buttonshow.on_click(showcols)
curdoc().add_root(row([selectviews,selectcols,buttonshow]))
Am Mittwoch, 6. Juli 2016 14:56:36 UTC+2 schrieb Bryan Van de ven:
> On Jul 6, 2016, at 7:19 AM, 'the_driver02' via Bokeh Discussion - Public <[email protected]> wrote:
>
> Hello,
>
> I'am searching for the same thing.
>
> My project has two select fields. The first selection generates a list, which I want show in the second selection.
> The callback works but the new list isn't show in the second selection.
> I use the options property, like Bryan suggested.
But how exactly, what exactly did you try? Can you share actual code? It is impossible to speculate on what might be amiss without seeing/trying real code.
Thanks,
Bryan
> Is there a solution???
> Is it possible to update a Select widget?
>
> Thanks for the 0.12 version. I like the new layout.
>
> Best regards
>
> the_driver02
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.
> To post to this group, send email to bo...@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/ae84e4ae-49d4-4e65-9065-bf03d933740f%40continuum.io\.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/ebb6dca3-008a-4e20-adfe-05f2ab8b1dab%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.