I am working with two Select-widget where one of them (select_2) is inside a class. Whenever I change the select_1, which is not part of the class, select_2 goes back to the first value which has been chosen.
What I want:
I want to achieve that the value of select_2 always keep and does not get affected by changes in select_1
What I tried:
I tried to use the value of select_2 as an input-variable of the class. However this works only until i change select_1 for the first time.
- Change select_2 from ‘first’ to ‘second’
- Change select_1 from A to B.
- Change select_2 from ‘second’ to ‘first’
- Change select_1 from B to A
after step 4 the value of select_2 changes to ‘second’ again.
What can I do so that after step 4 the value of select_2 stays as it is? Thanks in advance for help!
from bokeh.io import curdoc from bokeh.models import Select from bokeh.layouts import column col=['A','B'] select_1 = Select(title='select_1', value='A', options=col) class one(): def __init__(self, selection): self.selection=selection self.col=['first','second'] self.select_2 = Select(title='select_2', value=self.selection, options=self.col) a=one('first') select_2=a.select_2 def update(): print(a.select_2.value) layout.children = one(a.select_2.value).select_2 select_1.on_change("value", lambda attr, old, new: update()) layout=column(select_1,select_2) curdoc().add_root(layout)