0

It used to be in bokeh 1.4.0 that one could just do:

d=Dropdown(..., value='asdf')

To set an initial value to the dropdown. Then it could be read or modified by

d2 = d.value

or

d.value = 'sdfg'

In 2.0.0 this has been deprecated. See release notes

As mentioned in this answer they now seem to want you to just grab the value off of the event that comes as argument to the callback. But then:

  1. That seems to mean that if you want to "read" the value of the dropdown, you can't just query the dropdown model instance itself. You have to store it in a separate variable somewhere, which to me seems slightly inconvenient.

  2. I don't know if there is any way to programmatically set...

    a. the initial value of the dropdown if it is not the first thing in the menu (this is absolutely necessary for certain applications which might need to pre-populate the dropdown selection from something coming in as an argument via POST for example)

    b. the value at runtime. This seems like a basic capability of a dropdown control... other widgets allow changes to the text or value that they contain, so I don't know why it would be dropped. I don't see anything in the bokeh docs.

cab
  • 1
  • 1

1 Answers1

0

Nevermind. Now that I look at the dropdown control again I realize the new API matches the actual UI control. There is nothing visually selected within the list. Every time you drop it down it looks the same. So it makes sense to only have the value clicked be provided in the event argument (event.item). e.g.

dropdown = Dropdown(...)

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

dropdown.on_click(dropdown_handler)
cab
  • 1
  • 1