Get updated widget value, which is inside of a class

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.


  1. Change select_2 from ‘first’ to ‘second’
  2. Change select_1 from A to B.
  3. Change select_2 from ‘second’ to ‘first’
  4. 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!

Working example:

from import curdoc
from bokeh.models import Select
from bokeh.layouts import column

select_1 = Select(title='select_1', value='A', options=col)

class one():
    def __init__(self, selection):
        self.select_2 = Select(title='select_2', value=self.selection, options=self.col)


def update():
    layout.children[1] = one(a.select_2.value).select_2

select_1.on_change("value", lambda attr, old, new: update())


The update function refers to which never changes, because a never changes. When the callback is called after the first invocation, it’s referring to a Select object that still exists as an object, but it no longer the Select object that is actually rendered for users to interact with (because you replaced the the item in the layout. To get the current value of the Select that is actually displayed, you should use the Select object that’s inside the layout.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.