1

bokeh 1.4.0

>>> import bokeh
>>> bokeh.__version__
'1.4.0'
>>> from bokeh.models import Dropdown
>>> Dropdown().value is None
True

bokeh 2.0

>>> import bokeh
>>> bokeh.__version__
'2.0.0'
>>> from bokeh.models import Dropdown
>>> Dropdown().value is None
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Dropdown' object has no attribute 'value'

Is there another attribute that is meant to be used now in place of value?

see here for a use-case of the value attribute.

Russell Burdt
  • 2,391
  • 2
  • 19
  • 30

1 Answers1

4

Dropdown.value was an implementation detail that was not meant to be used by Bokeh users, according to its docstring. Apart from that, Dropdown semantically is just a collection of buttons. It should not have any sort of state, it should just dispatch the on_click event as a regular button, just as it does in 2.0. And that's why the value attribute has been removed in 2.0.0.

In order to trigger Python code on a dropdown button click, you can use something like

from bokeh.models import Dropdown

d = Dropdown(label='Click me', menu=['a', 'b', 'c'])


def handler(event):
    print(event.item)


d.on_click(handler)

event.item will contain the menu item that you have clicked.

Eugene Pakhomov
  • 9,309
  • 3
  • 27
  • 53